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

Reply
 
Thread Tools Display Modes
  #11  
Old 11-16-2009, 03:32 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Omegatron View Post
yeah you did I tried the str_replace and it did not work I asked if you knew why it did not.
I can't follow this on two sites. I guess I'll check the other thread tomorrow morning. However, if you didn't post all your code over there, then I'm not gonna be able to help. (Actually, you should probably continue this over here if you need code help since they don't like discussing plugin code and such over there.) So, post your code here and we'll see if we can figure out what is wrong. Include template code if you are calling templates also.
Reply With Quote
  #12  
Old 11-16-2009, 05:58 AM
Pitman's Avatar
Pitman Pitman is offline
 
Join Date: Dec 2001
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
First, you need to register the variables you will be using in the template and then you need to render it.
Example from one of mine using a template_hook:
PHP Code:
    $templater vB_Template::create('my_custom_template'); 
        
$templater->register('a_variable '$a_variable); 
    
$template_hook['some_hook'] .= $templater->render(); 
or - using a variable (which must then be registered for us in the next template):
PHP Code:
    $templater vB_Template::create('my_custom_template'); 
        
$templater->register('a_variable '$a_variable);
    
$somevariable .= $templater->render(); 
or - print_output:
PHP Code:
    $templater vB_Template::create('my_custom_template'); 
        
$templater->register('a_variable '$a_variable);
    
print_output($templater->render()); 
There is a blog entry by Kier over on vb.com that shows this.
I'm not a coder or anything, but I do require certain small plugins that would most likely be only useful for me. I have played with these examples, as well as ones previously provided on vBulletin.com, but have failed to wrap my head around how it is actually supposed to work. In my case, I simply need to be able to use a custom variable containing data in templates. One simple example of this would be as follows:
PHP Code:
$random_number rand(1105); 
How exactly should the plugin be formulated to make the variable $random_number accessible in the header template?
Reply With Quote
  #13  
Old 11-16-2009, 09:23 AM
Omegatron Omegatron is offline
 
Join Date: Feb 2003
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

well your plugin would hook where ever you wish and to access the variable in the header template it would be something like this

{vb:raw random_number}

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

Lynne thanks I posted there because its a huge design flaw in the new system IMO. I added my own hook name and it works fine but using the str_replace or something is needed I think because the whole point of the plugin system is to NOT make hand edits to files templates etc.

anyway here is the code I posted using etc


Template question for plugins.

Now say for instance I want to show a block of info on forumhome. I know I can do this since the template_hook is now a super global.

Code:
    $templater = vB_Template::create('forumhome_addon');
    $templater->register_page_templates();
    $templater->register('block_info', $block_info);
    $template_hook['navbar_end'] .= $templater->render();
That works fine prints the block at the end of the navbar and everything is fine. But I dont want it there. See in vb3 you did a fetch_template and str_replace on the $navbar variable and added your template under so it showed up before your forum list. This is what I want to be able to add a block of info before the $forumbits. Nothing I do a str_replace on works because there is no hook there. The plugin is at forumhome_complete and this does not work

Code:
    $templater = vB_Template::create('forumhome_addon');
    $templater->register_page_templates();
    $templater->register('block_info', $block_info);
    $thistemplater = $templater->render();
     
    $search_text = '<div id=\"pagetitle\">';
    $vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,$thistemplater.$search_text,$vbulletin->templatecache['FORUMHOME']);
I have tried doing a str_replace for that div tag or forumbits etc. Anyone have any hints on how to get it to work where I want it. Like I said it works fine if like add my new template into the actual template hook but thats the wrong location. There is no hook it seems at the top of the forum which IMO is an oversight on IB's part since in vb3 the top of the forumhome was right after $navbar and now it isnt
Reply With Quote
  #14  
Old 11-16-2009, 09:43 AM
Pitman's Avatar
Pitman Pitman is offline
 
Join Date: Dec 2001
Posts: 99
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Omegatron View Post
well your plugin would hook where ever you wish and to access the variable in the header template it would be something like this

{vb:raw random_number}
Well, I understand that much of it, but I'm not sure about how to go about formatting the plugin and registering the variable in the way that I need to. Any way that I've tried to register the variable in the provided examples I've seen anywhere have proved to be ineffective. I understand how to use the variable in the templates, but I'm unsure of how to correctly register the variable in the plugin while effectively being able to use {vb:raw random_number} in a specific and already available template.

Furthermore, while providing more information, in the following example:
PHP Code:
    $templater vB_Template::create('my_custom_template'); 
        
$templater->register('a_variable '$a_variable);
    
$somevariable .= $templater->render(); 
I only understand the $templater->register('a_variable ', $a_variable); there. Being that I'm not creating a template, the first line of code makes no sense to me. I also do not understand the render code or what I should use there either.
Reply With Quote
  #15  
Old 11-16-2009, 10:34 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Omegatron View Post
Lynne thanks I posted there because its a huge design flaw in the new system IMO.
What design flaw do you mean exactly ?
Reply With Quote
  #16  
Old 11-16-2009, 10:52 AM
Omegatron Omegatron is offline
 
Join Date: Feb 2003
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well if you can no longer display a block before the forumbits because you can not longer do a str_replace and there is not a hook for there its a design flaw. I do not beleive the point of vb4 was to go backwards from vb3 in the plugin system. if vb is going to make the only way you can include a template is through the hook system since its a superglobal then they need to do hooks everywhere. The whole purpose of the plugin system is to keep you from having to hack vb files templates.

i did what I needed to do by creating a new template hook name and editing the forumhome template to include the template hook where i wanted it. Remember in vb3 how alot of hacks appeared right before the forumbits or right after. there are no hook locations in forumhome other than in who's online. In vb3 you just did a str_replace to print your template right after the navbar. So if you can not longer do a str_replace and have to use a hook instead and there are non then its a design flaw especially somewhere as prized a location as the top of bottom of the forumbits. Just my Opinion

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

Pitman

You need to register any variables for use in a template. The initial post in this thread by lynne gives examples
Reply With Quote
  #17  
Old 11-16-2009, 10:59 AM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think there's now a way to preRegister the variables, so as i understood it, you'll need no more str_replace

I hope realy that there will be some great articles for vB4.
The best way would be, if some vbulletin developers would write articles, because they could show "us" the best way to extend vB4
Reply With Quote
  #18  
Old 11-16-2009, 11:48 AM
Yellow Slider Yellow Slider is offline
 
Join Date: Aug 2006
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
a_variable is the name of the variable you are registering. $tagforms was supposed to be $a_variable, but I forgot to change it - it is now changed. As for the $template_hook, that would be the name of the template_hook you are trying to use.... if you are using a template_hook. I gave several examples up there - you would not use them all for one template call.
Unfortunately, it still doesn't work for me.
For example, if i want to use the template_hook method, and my template name is abc, my var name is var, and i want to use it in the forumhome template, the code should be something like this?
PHP Code:
    $templater vB_Template::create('abc'); 
        
$templater->register('var '$var); 
    
$template_hook['forumhome'] .= $templater->render(); 
Reply With Quote
  #19  
Old 11-16-2009, 12:13 PM
Shadab's Avatar
Shadab Shadab is offline
 
Join Date: Apr 2007
Location: Bhopal
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

@Yellow Slider:

If I understand correctly, you want to evaluate the template "abc"
and make the result available in the FORUMHOME template via the variable "var" ?
Reply With Quote
  #20  
Old 11-16-2009, 12:20 PM
Yellow Slider Yellow Slider is offline
 
Join Date: Aug 2006
Posts: 249
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Shadab View Post
@Yellow Slider:

If I understand correctly, you want to evaluate the template "abc"
and make the result available in the FORUMHOME template via the variable "var" ?
Yes.
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:08 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.04210 seconds
  • Memory Usage 2,285KB
  • Queries Executed 11 (?)
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
  • (2)bbcode_code
  • (6)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete