Hello all...
I had the problem that on many websites i made clicking on an menuitem wich has siblings under it, the preferred action was not to go to the content of the clicked menu item but instead go directly to the first sibling of this item. I hope you know what i mean...
lets say you have something like this:
- Home
- News
- about me
- sports
- profile
- Contact
- impressum
by clicking on "about me" , WB should jump directly to the sibling "sports".
I tried this with module "menulink" but it didnt all work for me. Causing problems with creation of the php files in the pages Directory, and of course changing the order of the siblings resulted in changing also the menulink if the first sibling changed...
So I wrote a code snipet called: goto_first_sibling. Its working fine for me. I only tested it on WB2.6.7 (on LAMP-System using php4), but it should work on older releases i think.
This small snippet does nothing else than if the function is called from beginning of the template, it checks for an sibling of the current clicked menu item. If there is a sibling, get the link of this site and send an header("Location:...) and afterwards exit from the current code execution.
I also made the oportunity to exclude certain page_ids from this behaviour. But its all explained in the readme.txt in the zip-file. Here is the content of it:
+++++++++++++++++++++++++++++++++++++++++++++++++
function goto_sibling:
***********************************************
** Version 0.9: ** | author: gingebaker
***********************************************
This function is for automatically redirecting to the first sibling (if it exists and no headers where currently sent) from the current page.
USAGE:
goto_first_sibling([$exceptions]);
the $exceptions variable is an array where you put all the page_ids in where you dont want an redirect to occur.
for example:
<?php goto_first_sibling(array(10,12,15)); ?>
if you dont have any exceptions and you want the script to do it with all your pages just add:
<?php goto_first_sibling(); ?>
You should put this function call to the very top of your template file. So that no output started before the call
+++++++++++++++++++++++++++++++++++++++++++++++++Install it the normal way in the WB-backend -> Modules
What you think about this? Is there a slicker way you can think of??
Any comments would be appreciated. And I hope you´ll find it useful. If anybody finds a bug or error please reply to me...
WB rules...
