vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

masterross 03-03-2010 09:45 PM

Quote:

Originally Posted by TalkVirginia (Post 1996431)
I'm trying to append some text to the end of the footer.. in a plugin.. but I'm totally lost.

How do I get the footer out of the cache to append some text to it?

Why dont you use ad_footer_end hook?

TalkVirginia 03-04-2010 09:44 AM

Quote:

Originally Posted by testebr (Post 1916821)
I figure out how to solve it:

hook: process_templates_complete

code: $footer .= 'text added to footer';

No idea if was the best solution, but that worked very well.

Quote:

Originally Posted by cellarius (Post 1916832)
Indeed, you can manipulate the already rendered template doing this. Also possible is str_replace:
PHP Code:

$search "Terms of Service";
$replace "Terms of Cooking Noodles";
$footer str_replace($search,$replace,$footer); 

Although this is a somewhat bad example, since "Terms of Service" is a phrase, of course, and will vary by language. Always make sure you use strings for replacement that are always present.

Attachment 106372

Using str_replace, you can also add stuff in the middle of the template like so:
PHP Code:

$search "Terms of Service";
$replace " and Terms of Cooking Noodles";
$footer str_replace($search,$search.$replace,$footer); 

Attachment 106374

Testbr and Cellarius - Thank you so much! I finally found your post which solved my issue. After seeing it, it's so simple I felt like smacking myself.. LOL :eek: :facepalm:

abomohammad 03-06-2010 05:21 PM

Hi , I need for help

I created a template called: my_template
and write "Hi" inside it.

I want to get "Hi" in my FORUMHOME template
so i made a plugin on global_start and put:

PHP Code:

$templater vB_Template::create('my_template');
  
$templater->register('my_var'$my_var);
$templater->render(); 

then i post {vb:raw my_var} in FORUMHOME
but nothing apper to me

How to get my_template content in FORUMHOME or other template ???

masterross 03-06-2010 07:10 PM

Quote:

Originally Posted by abomohammad (Post 1998597)
Hi , I need for help

I created a template called: my_template
and write "Hi" inside it.

I want to get "Hi" in my FORUMHOME template
so i made a plugin on global_start and put:

PHP Code:

$templater vB_Template::create('my_template');
  
$templater->register('my_var'$my_var);
$templater->render(); 

then i post {vb:raw my_var} in FORUMHOME
but nothing apper to me

How to get my_template content in FORUMHOME or other template ???

Did you read the fist post in the thread?

PHP Code:

$templater vB_Template::create('mytemplate');
    
$templater->register('my_var'$my_var);
    
$templater->register('my_array'$my_array);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 


abomohammad 03-06-2010 10:51 PM

Quote:

Originally Posted by masterross (Post 1998671)
Did you read the fist post in the thread?

PHP Code:

$templater vB_Template::create('mytemplate');
    
$templater->register('my_var'$my_var);
    
$templater->register('my_array'$my_array);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 


Yes, I read it, but do not work :confused:

Joseph Witchard 03-07-2010 02:43 AM

I apologize for sounding so helpless, but what exactly do you do with templates, and where do you even go to put in the PHP code for them? I opened this article thinking it was about skins. I'll continue to look for a thread about skins, but all this sounds like it's also important on modifying vBulletin to suit your needs, so that's why I'm posting here.

masterross 03-07-2010 06:29 AM

Quote:

Originally Posted by abomohammad (Post 1998766)
Yes, I read it, but do not work :confused:

you also need to use right hook location!
For FORUMNOME probably will be forumhome_start or forumhome_complete


Regards!

TalkVirginia 03-07-2010 11:53 AM

Is it possible to use a custom template and render it into a variable then use that variable in sending HTML email?

I'm trying to use the following PHP code:

PHP Code:


$templater 
vB_Template::create('mycustom_template');
$templater->register('username'$username);
$templater->register('bbtitle'$bbtitle);
$templater->register('homeurl'$homeurl);
$templater->register('forumurl'$forumurl);
$templater->register('hometitle'$hometitle);
$message $templater->render(); 

I have the following variables defined in my template:

Code:


{vb:raw username}
{vb:raw bbtitle}
{vb:raw homeurl}
{vb:raw forumurl}
{vb:raw hometitle}


princeedward 03-12-2010 08:47 PM

thanks for this and hope that someday i can do this too alone and well enough of my own without error...but it's not quite easy at all to understand...just to be honest....:p

well i was about experimenting to show the Current Activity of the Currently Active Members above inside WGO BOX (by mouse hover to the username)....by adding the red code below

Code:

<li> {vb:stylevar dirmark}<a class="username" href="{vb:link member, {vb:raw loggedin}}" title="{vb:rawphrase current_activity} {vb:raw loggedin.action} {vb:raw loggedin.where}
">{vb:raw loggedin.musername}</a>{vb:raw loggedin.invisiblemark}{vb:raw loggedin.buddymark}</li>

...to the vbdefault template of forumhome_loggedinuser but it didn't quite well and good even i tried to preregistered those variables....well i'm not sure too if i did it right or not...


PHP Code:

vB_Template::preRegister('FORUMHOME',array(
'loggedin.action ' => $loggedin.action));  
'loggedin.where ' => $loggedin.where)); 

can anyone guide me on this please...
thanks and best regards to all

:o

cellarius 03-12-2010 09:38 PM

$loggedin.action or $loggedin.where are not valid PHP variables. I do not think that this is just a registering problem. You should probably open your own thread in the forums and explain exactly what and how you are trying to do.


All times are GMT. The time now is 05:45 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.01441 seconds
  • Memory Usage 1,776KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (8)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete