Unfortunately Drupal only allows you to add primary and secondary menu’s by default. However there are times you need deeper levels, for example a third (tertiary) level submenu.
After some searching and looking at the core code I came up with a pretty easy solution.
First add the following functions to your template.php file.
function phptemplate_preprocess_page(&$vars) {
$vars['tertiary_links'] = menu_tertiary_links();
}
/**
* Returns an array containing the tertiary links based on the primary menu.
* Tertiary links can be either a third level of the Primary links
* menu or generated from a second level of the explicitly defined secondary_menu
*/
function menu_tertiary_links() {
if (variable_get('menu_secondary_links_source', 'secondary-links') == variable_get('menu_primary_links_source', 'primary-links')) {
return menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 2);
}
else {
return menu_navigation_links(variable_get('menu_secondary_links_source', 'secondary-links'), 3);
}
}
Once you’ve done that, you can add this snippet in your template.
<?php if (isset($tertiary_links)): ?>
<?php print theme('links', $tertiary_links, array('class' => 'links tertiary-links')); ?>
<?php endif; ?>
And voila! you’re done.
Today my Soap datasource has been added into the Cakephp datasources repository by Graham Weldon.
Great to see my work got accepted.
Here’s a little snippet of code that let’s you create sticky toolbars like they use in Magento for example :)
Read the full article
Just like many other CakePHP bloggers out there, I also received a copy of Cakephp Application Development written by Ahsanul Bari and Anupom Syam, published by PACKT publishing.
The first thing I noticed were the cake’s printed on the cover, they don’t look really tasty to me because of the odd colors. Thankfully the inside of the book looked much better.
Read the full article
There may be times when you want to edit some variables in for example a database connection file, to run an application right from within your GIT repo. Of course you don’t wont those changes to be commited, so you add the file the .gitignore.
However adding tracked files to .gitignore won’t work because GIT will still track the changes and commit the file if you use the -a parameter.
Fortunately GIT has a very easy solution for this, just run the following command on the file or path you want to ignore the changes of:
git update-index --assume-unchanged <file>
If you wanna start tracking changes again run the following command:
git update-index --no-assume-unchanged <file>
You can find more info about this in the git manual.
Happy GITting ;)