Register Members List Search Today's Posts Mark Forums Read

Reply
 
Article Options
  #151  
Old 02 Apr 2011, 08:12
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Originally Posted by TalkVirginia View Post
I'm trying to capture a rendered/parsed template to a variable like so:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

I would expect that myvar would contain the parsed template, but it comes up empty.

Can anyone help me?
This:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


should be this:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #152  
Old 05 Apr 2011, 21:49
rlarner's Avatar
rlarner rlarner is offline
 
Join Date: Apr 2011
I'm struggling with getting data from a variable into one of the stock templates. Here's what I've done:
Created a custom plugin with the hook location set to "global_start":
$roscohtml = "<div>HELLO WORLD!</div>";
error_log($roscohtml);
vB_Template:reRegister('header',array('roscohtml'=>$roscohtml));

Then I customized the header template to contain this:
<div class="above_body"> <!-- closing tag is in template navbar -->
<div>test before</div>
{vb:raw roscohtml}
<div>test after</div>

Unfortunately the variable isn't being output. I do see the contents in the error log, so I know it's firing.

Any tips?

Thanks,
Rosco

--------------- Added 05 Apr 2011 at 22:32 ---------------

OK, I think I found the problem - the global_start hook is not the right place for this to live. I moved my code to the parse_templates hook and the data is now available.

Is there a document which outlines the best way to leverage the hooks, or at least where each is called in the flow?

Rosco

Last edited by rlarner; 05 Apr 2011 at 22:32. Reason: Auto-Merged DoublePost
Reply With Quote
  #153  
Old 25 Apr 2011, 20:42
bela-meaad bela-meaad is offline
 
Join Date: Jan 2005
Real name: Abdul
as templates no longer get output using eval
i tried to change it but seems not working.

can anyone help me with this code?



Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #154  
Old 07 May 2011, 16:48
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
http://www.vbulletin.org/forum/showp...&postcount=151
Reply With Quote
  #155  
Old 05 Jul 2011, 21:09
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
 
Join Date: Jun 2008
Real name: Joe D.
I hoping this isn't too far off topic bt if possible I think it would make a good addition to the article...

What if I want to override an existing template with a new template. Basically ignore whatever is in a given template and render a new template, and copy the new template to the old template? Is that possible?

I've tried stuff like:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

in all the various template hooks to no avail. I've also tried using $vbulletin->templatecache['existing_vb_template'] in the last line instead of $globaltemplates and also did not work.

Is what I'm asking possible? Seems like it should be... Any input would be appreciated.
__________________
-Joe
Former vb.org Moderator. Retired.

@BirdOPrey5 | All Things BOP5 | Joe's Ultimate Off Topic
Note - I no longer making new VB mods, sorry.
Reply With Quote
  #156  
Old 05 Jul 2011, 21:58
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Yes, it can be done easily, if what you are wanting is what I understand it to be. As an example, here is what I did for that:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #157  
Old 05 Jul 2011, 23:40
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
 
Join Date: Jun 2008
Real name: Joe D.
Great, Thanks Boofo!

It might be worth mentioning for anyone else- you have to register any variables used to the ORIGINAL template (the one you are overriding) not the new template... At least that's the only way it's working for me. (On parse_templates hook)
__________________
-Joe
Former vb.org Moderator. Retired.

@BirdOPrey5 | All Things BOP5 | Joe's Ultimate Off Topic
Note - I no longer making new VB mods, sorry.
Reply With Quote
  #158  
Old 06 Jul 2011, 00:12
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Are you sure? I used the same variables when I did it but I would think you only need to pre-register the variables you are going to use, not the other way around.

I did the above code in forumhome_start. Did you try the process_templates_complete hook?
Reply With Quote
  #159  
Old 06 Jul 2011, 02:34
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
 
Join Date: Jun 2008
Real name: Joe D.
Maybe I didn't explain it right... in your example registering callink and the others to boofo_forumhome_event didn't do anything for me- I had to preRegister them to forumhome_event for them to work. I tried both parse_templates and process_templates_complete hooks.

To me it makes sense since the forum thinks it's outputting forumhome_event, and this is confirmed by viewing template names in the HTML source code.
__________________
-Joe
Former vb.org Moderator. Retired.

@BirdOPrey5 | All Things BOP5 | Joe's Ultimate Off Topic
Note - I no longer making new VB mods, sorry.
Reply With Quote
  #160  
Old 06 Jul 2011, 02:53
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Real name: Rob
Well, yes and no. Since I did it in the forumhome_start hook, it needed those pre-registered for my new template. As long as the variables are good at that hook, then it will work the way I did it.

The forumhome doesn't care about the old template as long as I pre-register everything for my new template. Doing it in the parse_templates hook might be why it didn't work for you with your code. You would have to check whether whatever variables you are pre-registering have already been validated at whatever hook you are using.

Now I'm getting confused. And it hurts! LOL
Reply With Quote
  #161  
Old 06 Jul 2011, 03:45
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
 
Join Date: Jun 2008
Real name: Joe D.
Originally Posted by Boofo View Post
Well, yes and no. Since I did it in the forumhome_start hook, it needed those pre-registered for my new template. As long as the variables are good at that hook, then it will work the way I did it.

The forumhome doesn't care about the old template as long as I pre-register everything for my new template. Doing it in the parse_templates hook might be why it didn't work for you with your code. You would have to check whether whatever variables you are pre-registering have already been validated at whatever hook you are using.

Now I'm getting confused. And it hurts! LOL
Don't be confused- the important thing is it works and all is well.
__________________
-Joe
Former vb.org Moderator. Retired.

@BirdOPrey5 | All Things BOP5 | Joe's Ultimate Off Topic
Note - I no longer making new VB mods, sorry.
Reply With Quote
  #162  
Old 08 Jul 2011, 18:38
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Hello everyone, I have been reading this article over and over again trying to figure out what I am doing wrong. Basically I am trying to put the contents of one template into another using a plug in. The template in question are:

-OFTW
-COFTW_FAQ

I want to be able to put the contents of template COFTW_FAQ into a variable that I can then use in OFTW template. I am using a script (oftw.php) which uses the OFTW template; I need to be able to insert the contents of COFTW_FAQ into that template using a plug-in. So this is what I have so far:

Plug-in 1: Hook: Global Start


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plug-in 2: Hook: Global Start


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And I am using the following variable to call the contents of COFTW_FAQ into OFTW template:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

With no avail; I get a blank where the content of the variable should be. Any ideas what I am doing wrong anyone??

Please Help I have been hitting myself in the head for the last 4 hours!

--------------- Added 09 Jul 2011 at 00:06 ---------------

UPDATE!!!

After more thinking... I can see that I was a bit off, I am now using only plug in to try and accomplish what I want but still just blank...

Hook Location: Process Templates Complete

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Using: {vb:raw oftw_faq} in the OFTW template but still nothing... Am I getting closer???

--------------- Added 09 Jul 2011 at 16:22 ---------------

GOT IT!!! FINALLLLY!!!!! xD

I had to just register my variable in the actual oftw.php file . Since it was a custom page the script did not have the variable registered so I added
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

to the oftw.php file and added the last plug-in above and voila! Perfect!! This opens up a whole new world for me. Anywho, just thought i'd share my conquering

Last edited by EquinoxWorld; 09 Jul 2011 at 16:54.
Reply With Quote
  #163  
Old 11 Jul 2011, 07:34
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
Congrats - good to see you got it working
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #164  
Old 11 Jul 2011, 14:19
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
 
Join Date: Jun 2008
Real name: Joe D.
Originally Posted by EquinoxWorld View Post
Hello everyone, I have been reading this article over and over again trying to figure out what I am doing wrong. Basically I am trying to put the contents of one template into another using a plug in. The template in question are:

-OFTW
-COFTW_FAQ

I want to be able to put the contents of template COFTW_FAQ into a variable that I can then use in OFTW template. I am using a script (oftw.php) which uses the OFTW template; I need to be able to insert the contents of COFTW_FAQ into that template using a plug-in. So this is what I have so far:

Plug-in 1: Hook: Global Start
...
As has been mentioned here before global_start is a bad hook to use in VB4. It was included for compatibility with older mods and is expected to be removed at some point- you can't count on it existing in non-forum parts of the site.

global_bootstrap_init_start should be used instead of global_start in most circumstances.
__________________
-Joe
Former vb.org Moderator. Retired.

@BirdOPrey5 | All Things BOP5 | Joe's Ultimate Off Topic
Note - I no longer making new VB mods, sorry.
Reply With Quote
  #165  
Old 11 Jul 2011, 21:17
EquinoxWorld EquinoxWorld is offline
 
Join Date: Nov 2009
Originally Posted by BirdOPrey5 View Post
As has been mentioned here before global_start is a bad hook to use in VB4. It was included for compatibility with older mods and is expected to be removed at some point- you can't count on it existing in non-forum parts of the site.

global_bootstrap_init_start should be used instead of global_start in most circumstances.
For rendering template and such which is the most recommended then? I'm assuming "process_template_complete" ? Or does it depend on each case?
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 01:38.

Layout Options | Width: Wide Color: