![]() |
Using vbulletin IF conditionals in a module
Hello, I had a menu strip that shows different options to different usergroups.
For instance: PHP Code:
Since I have two skins, I had to keep updating this menu strip in both skins whenever it needed to be changed. So i figured I could put the menu strip in a separate PHP file and create a Module (in the Plugins & Products System section). That way I would only have to edit it once. So in the Header of each skin's Common Templates, I replaced the menu strip with the variable $hgNavStrip and then I created a module defining it: PHP Code:
I think I am perhaps not using the right Hook Location or Execution Order. I am currently using a Hook Location of: global_start and an Execution Order of 5. Most of the other Hook Locations I have tried don't show the menu strip at all, but parse_template and init_startup also work, but similarly they ignore the vB conditionals. If someone could please let me know how to resolve my issue I would be most appreciative. |
If you are going to go it in a php file, you need to write the conditions in php. For instance:
PHP Code:
|
Thank you. I didn't know I could do that. It works perfect
However, what about links like this? They still don't work. PHP Code:
Could it be something like this? (with concatenation dots (.) in the URL?) I do not understand what the $session[] array does in the middle of the link. PHP Code:
|
Yes, you are on the right track. :)
|
Hey thanks for helping me. I got most of those working. Here is what I did:
PHP Code:
PHP Code:
|
If you are expecting a dropdown, you have more code you need to add to the navbar. Do a search on "dropdown" or "navbar" in "articles" "titles only" and you should find an article on how to add dropdowns to the navbar.
|
Dear Lynne,
This dropdown works fine when it is in Style Manager; it doesn't need any more code. I just need to translate it properly from the following code block into PHP so I can take it out of Style Manager and put it in the PHP module. This works: HTML Code:
<a id="navbar_search" href="/forums/search.php$session[sessionurl_q]"> Search </a><if condition="$show['quicksearch']"><script type="text/javascript"> vbmenu_register("navbar_search", 1); </script></if> Code:
Array ( [search_engine] => [old_explorer] => [left_column] => 1 [center_column] => 1 [right_column] => 1 [editor_css] => [xfire] => ) |
$show is a variable vbulletin uses to determine whether something should be shown. All the permissions for the forum and the user are looked at and then it is determined if something should be 'shown' for that user. If it should, it is set to true. If not, the default is false. If the code needed to determine if $show['whatever'] is not present to set that variable to true, it will stay at false. If you don't care about that variable, then just don't use it.
|
hmm that's weird why $show[] would include 'quicksearch' for me normally, but now when I moved it to a PHP module it only includes the things I pasted above.
I thought perhaps I was not looking at the right $show[] (maybe there is a $show[] in the $vbulletin class instance like $vbulletin->show[] ?) |
All times are GMT. The time now is 04:05 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|