Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-30-2009, 12:08 AM
helltonic helltonic is offline
 
Join Date: Oct 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using vbulletin IF conditionals in a module

Hello, I had a menu strip that shows different options to different usergroups.

For instance:
PHP Code:
<if condition="is_member_of($vbulletin->userinfo, 21, 13)">
    <
li><a href="/forums/forumdisplay.php?f=7"><font color="gold">Forum 21</font></a></li>
    <
li><a href="/forums/forumdisplay.php?f=8"><font color="lime">Forum 13</font></a></li>
</if> 
This was originally written in the Header area of Common Templates, which is in Style Manager.

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:
ob_start();
include(
'/home/mydomain/public_html/navstrip/navstrip.php');
$hgNavStrip ob_get_contents();
ob_end_clean(); 
Well, the menu strip shows up, but all the vB conditionals are ignored. It's like it doesn't know the user's state anymore.

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.
Reply With Quote
  #2  
Old 09-30-2009, 03:39 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are going to go it in a php file, you need to write the conditions in php. For instance:
PHP Code:
if (is_member_of($vbulletin->userinfo2113)) {
stuff

Reply With Quote
  #3  
Old 09-30-2009, 05:20 AM
helltonic helltonic is offline
 
Join Date: Oct 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
<a href="/forums/$vboptions[forumhome].php$session[sessionurl_q]">link</a>

<
a href="/forums/search.php?$session[sessionurl]do=getnew">link</a>

<
a href="/forums/memberlist.php$session[sessionurl_q]">link</a>

<
a href="/forums/search.php$session[sessionurl_q]">link</a
--------------- Added [DATE]1254323020[/DATE] at [TIME]1254323020[/TIME] ---------------

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:

<?php echo('<a href="/forums/'.$vbulletin->options['forumhome'].'.php'.$vbulletin->session->vars['sessionurl_q'].'">link</a>'?>
Sorry, but I am not at my normal PC right now. Please let me know if I am on the right track. Thank you
Reply With Quote
  #4  
Old 09-30-2009, 03:00 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, you are on the right track.
Reply With Quote
  #5  
Old 10-01-2009, 02:13 AM
helltonic helltonic is offline
 
Join Date: Oct 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hey thanks for helping me. I got most of those working. Here is what I did:

PHP Code:
<?php /* Forum index */
    
$href '/forums/'.$vbulletin->options['forumhome'].'.php'.$vbulletin->session->vars['sessionurl_q'];
    
$innerHtml '&nbsp; Forums <img src="http://files.bortweb.com/hg/web/navstrip2/downarrow.png" border="0" />&nbsp;';
    echo(
'<a href="'.$href.'">'.$innerHtml.'</a>');
?>

<?php /* Get new posts */
    
$href '/forums/search.php?'.$vbulletin->session->vars['sessionurl'].'do=getnew';
    
$innerHtml '&nbsp; New Posts &nbsp;';
    echo(
'<a href="'.$href.'">'.$innerHtml.'</a>');
?>

<?php /* Forum member */
    
$href '/forums/memberlist.php'.$vbulletin->session->vars['sessionurl_q'];
    
$innerHtml '&nbsp; Members <img src="http://files.bortweb.com/hg/web/navstrip2/downarrow.png" border="0" />&nbsp;';
    echo(
'<a href="'.$href.'">'.$innerHtml.'</a>');
?>
I do still have one more question. The Search button is not registering to be a js dropdown. I think because I do not know the correct vB implementation of the $show[] array. Could you please help me with that? Here is what I have so far:

PHP Code:
<?php /* Search button or dropdown */
    
$href '/forums/search.php'.$vbulletin->session->vars['sessionurl_q'];
    
$innerHtml '&nbsp; Search &nbsp;';
    echo(
'<a id="navbar_search" href="'.$href.'">'.$innerHtml.'</a>');
    if(
$show['quicksearch'])
    {
        echo(
'<script type="text/javascript">vbmenu_register("navbar_search", 1);</script>');
    }
?>
Thank you
Reply With Quote
  #6  
Old 10-01-2009, 02:34 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 10-01-2009, 02:59 AM
helltonic helltonic is offline
 
Join Date: Oct 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]">&nbsp; Search &nbsp;</a><if condition="$show['quicksearch']"><script type="text/javascript"> vbmenu_register("navbar_search", 1); </script></if>
I believe the main reason why it is not working when I turn it into PHP is because I don't know what the PHP version is for the $show[] array. This is what I was trying to do in the last code block of my previous post. There is a $show[] array, but I am not sure it is correct b/c it does not contain 'quicksearch' as a member. Here is what it contains:

Code:
Array ( [search_engine] => [old_explorer] => [left_column] => 1 [center_column] => 1 [right_column] => 1 [editor_css] => [xfire] => )
Thanks!
Reply With Quote
  #8  
Old 10-01-2009, 03:02 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$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.
Reply With Quote
  #9  
Old 10-01-2009, 03:31 PM
helltonic helltonic is offline
 
Join Date: Oct 2008
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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[] ?)
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:15 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
  • Page Generation 0.11043 seconds
  • Memory Usage 2,278KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_html
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete