Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-01-2012, 03:15 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Whats Called Template Hook - Under the Navbar?

Hello Everyone,

I am making a product for vBulletin 4.2 and I have tried everything to add my Item under the NAVBAR. I am not much familiar with the Navbar and Navtab hooks, but I gave it a try... Just like showen in the Picture below:



Like showen on the Image, I know thats not below the HEADER, so I was thinking more about the NAVBAR and NAVTAB.. But this is where I want my item to show up like in the image. It does not show up there, but it does show on other hooks and spots! I wanted to know if I am missing something, Below is some ofl the hooks I tried..

The 2 Hooks below didn't even show the image:

Code:
{vb:raw template_hook.navbar_start}
{vb:raw template_hook.navbar_end}

Thes 2 Hooks did show the image, but not where I wanted them:

Code:
{vb:raw template_hook.navtab_start}
{vb:raw template_hook.navtab_end}
If someone could tell me what maybe could be wrong, or am I using the wong hooks! If YES, then what is the hook called right BELOW the navbar or navtab! I know its not the HEADER, so what can it be?

Thanks you very much in Advance, Regards CM

So far this is the full Navbar & Navtab Hooks list for vB4 that I got:
Code:
{vb:raw template_hook.navtab_start}
{vb:raw template_hook.navbar_start}
{vb:raw template_hook.navbar_after_getnew}
{vb:raw template_hook.navbar_after_pm}
{vb:raw template_hook.navbar_after_faq}
{vb:raw template_hook.navbar_after_calendar}
{vb:raw template_hook.navbar_community_menu_start}
{vb:raw template_hook.navbar_community_menu_end}
{vb:raw template_hook.navbar_after_community}
{vb:raw template_hook.navbar_quick_links_menu_pos1}
{vb:raw template_hook.navbar_quick_links_menu_pos2}
{vb:raw template_hook.navbar_quick_links_menu_pos3}
{vb:raw template_hook.navbar_quick_links_menu_pos4}
{vb:raw template_hook.navbar_end}
{vb:raw template_hook.navbar_start}
{vb:raw template_hook.navbar_after_getnew}
{vb:raw template_hook.navbar_after_pm}
{vb:raw template_hook.navbar_after_faq}
{vb:raw template_hook.navbar_after_calendar}
{vb:raw template_hook.navbar_community_menu_start}
{vb:raw template_hook.navbar_community_menu_end}
{vb:raw template_hook.navbar_after_community}
{vb:raw template_hook.navbar_quick_links_menu_pos1}
{vb:raw template_hook.navbar_quick_links_menu_pos2}
{vb:raw template_hook.navbar_quick_links_menu_pos3}
{vb:raw template_hook.navbar_quick_links_menu_pos4}
{vb:raw template_hook.navbar_end}
{vb:raw template_hook.navtab_middle}
{vb:raw template_hook.navbar_getnew_menu}
{vb:raw template_hook.navbar_getdaily_menu}
{vb:raw template_hook.navtab_end}
Reply With Quote
  #2  
Old 11-01-2012, 04:00 PM
TheSupportForum TheSupportForum is offline
 
Join Date: Jan 2007
Posts: 1,158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how are you adding content

personally i would use a plugin

$template_hook[navbar_end] .= 'content here';

you will also need to state Hook Location
Reply With Quote
  #3  
Old 11-01-2012, 04:13 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for Reply Simon:

Its a XML Product but its very long code and have 2 Template codes inside, but I have only had problems with the HOOKs, rest is going fine,, I am not good in PHP and this is why I always go STOP, Below is my the Hook code.. I suspecting the forumhome_start to be wrong which I actually just found out after so many hours.. still dont know if that could be the case..

and by the way, I use "cache templates" and not the "process templates" which may also indicate that it could be why!

Code:
<plugin active="1" executionorder="5">
            <title>Popup Navbar Image</title>
            <hookname>forumhome_start</hookname>
            <phpcode><![CDATA[global $vbulletin;
if ($vbulletin->options['navbar_image'])
{       $templater = vB_Template::create('navbar_image');
        $template_hook['navbar_end'] .= $templater->render();    

}]]></phpcode>
Thanks Simon
Reply With Quote
  #4  
Old 11-01-2012, 04:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using hook parse_templates, and if you only want it on the home page check for THIS_SCRIPT == 'index'.
Reply With Quote
  #5  
Old 11-01-2012, 04:42 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
Try using hook parse_templates, and if you only want it on the home page check for THIS_SCRIPT == 'index'.
I did the process_templates, instead of cache_templates maybe my code is wrong, here is my code:
Code:
        <plugin active="1" executionorder="5">
            <title>Cache Additional Notification Templates</title>
            <hookname>cache_templates</hookname>
            <phpcode><![CDATA[$cache = array_merge((array)$cache,array(
    'navbar_image',
));]]></phpcode>
        </plugin>
I was hoping you were on today.. I wanna add a simple "Login Field" on 1 line wich has 2 background images, 1 for Password Field and and 1 for the Username Field! Dont know if THIS_SCRIPT will help me if I want it to show up on all pages and for guest...

Now I am thinking to use the Replace code instead of hooks, I never found out how to Replace a code on vB4.2, but on my vB3.8 it was a success when I saw one of your and Scanus explanation!, But I keep failing using the Replace code on vB4.x.. Thats why I am only use hooks now :/

I have 2 different Replace codes, but didnt work on vB4.2, Can you please show how can I replace this instead of using the hooks... Thank you

Method 1:
Code:
$replace = 'REPLACE CODE';
        $vbulletin->templatecache['navbar'] =  str_replace($replace,'REPLACE  CODE'.$replace,$vbulletin->templatecache['postbit']);
Method 2:
Code:
$replace = 'REPLACE CODE';
        $vbulletin->templatecache['navbar'] =  str_replace($replace,$replace.'REPLACE  CODE',$vbulletin->templatecache['postbit']);
And below is the LAST part of my navbar template code! I wanna know which part is good to use for REPLACING, and to add my ITEM below navbar:

Code:
<div class="body_wrapper">

{vb:raw ad_location.ad_navbar_below}
{vb:raw ad_location.global_below_navbar}

<vb:if condition="$show['notices'] AND THIS_SCRIPT != 'register'">
    <form action="profile.php?do=dismissnotice" method="post" id="notices" class="notices">
        <input type="hidden" name="do" value="dismissnotice" />
        <input type="hidden" name="s" value="{vb:raw session.sessionurl}" />
        <input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
        <input type="hidden" id="dismiss_notice_hidden" name="dismiss_noticeid" value="" />
        <input type="hidden" name="url" value="{vb:raw return_link}" />
        <ol>
            {vb:raw notices}
        </ol>
    </form>
</vb:if>
Thank you very much
Reply With Quote
  #6  
Old 11-01-2012, 10:27 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Doing replaces in templates is a little more difficult with vb4 because what's stored in the cache is php code, so you have to make sure it's still valid php code after the replace. It still may be possible to do a replace like you would do in vb3, it depends on exactly what you're trying to replace. It might help to look at the "template" column in the template table in the database, or print out what's in the cache so you can figure out exactly what you need to do.

If I remember correctly the "REPLACE CODE' thing was solving a special problem, so you probably dont' need to do it that way.

Did you try using hook parse_templates? You mentioned process_templates, and I think there is a process_template_complete hook but it's called after the navbar is rendered so changing the cache at that point won't help.

OK, I just read the last part of your post above: If you just want to add something to the end of the navbar, then instead of doing a replace you could do this:

Code:
$vbulletin->templatecache['navbar'] .= "$final_rendered .= 'Add this stuff'";

But it might be a little tricky to get the quotes right. The other thing you could do is to find a hook that comes after the navbar is rendered (like process_templates_complete) and do something like:

Code:
$navbar .= "Add this stuff";
Which might be easier since you don't have to worry so much about the quotes.
Reply With Quote
  #7  
Old 11-01-2012, 11:36 PM
ChiNa ChiNa is offline
 
Join Date: Jul 2012
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So inspirational..... Thank you KH99,


I tried the first method and I got this error all the way:
Parse error: syntax error, unexpected T_STRING in /home/content/93/8491993/html/vb4test1/includes/class_bootstrap.php(561) : eval()'d code on line 49

I actually used the process_templates_complete as my my hookname, I will now try the 2nd method with the $navbar only.. and a few other hooks, hopefully by tomorrow I can possibly answer back on it and If I cant figure it out, Else I might add my whole Template code, so you can see the exact "Render" and "Process_Template" Codes, maybe I do it totally wrong..

Thanks a Lot buddy, I will def save your info, hopefully I can always use it no matter how many times I fail to finish my work..

--------------- Added [DATE]1351879808[/DATE] at [TIME]1351879808[/TIME] ---------------

Hi Kh99, I totally failed doing the Product, I get the parse error all the time.
Parse error: syntax error, unexpected T_STRING in /home/content/93/8491993/html/vb4test1/includes/class_bootstrap.php(561) : eval()'d code on line 49

I will try pm you with my product, hopefully you will take a look and tell me how the replace works, and if you could fix it for me then I would be more than greatfull

Thanks a lot kh99 for your help mate..
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 08:26 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04293 seconds
  • Memory Usage 2,238KB
  • 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
  • (10)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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