PDA

View Full Version : Duplicate Template Variables & Use It Within Another Template?


Freesteyelz
09-30-2007, 01:56 AM
I've read quite a bit of helpful threads/tutorials here. I know how to create a custom template and set it in plugins then call from within another template. I was wondering, however, how would I go about creating a template that uses the variables of an existing template such as "threadbit"? Example below...

I want to create a template called "threadbit_test". In it I want to copy/paste the content from "threadbit" template. I then want to use "threadbit_test" template inside "threadbit" template such as:

In threadbit template code applied:

<if condition="in_array($forumid, array(x,y,z))">
$threadbit_test
<else />
threadbit content here
</if>



For some reason the variables I took from threadbit template do not display in $threadbit_test? The only way (right now) I'm able to display the variables of threadbit template is to literally copy it and replace it where $threadbit_test is in the code example. It's rather cluttered.

Do I need to cache and parse the $threadbit_test template or hook it to threadbit_display or another area in the plugins such as global_start?

Your help is appreciated. :)

Dismounted
09-30-2007, 06:35 AM
eval('$threadbit_test = "' . fetch_template('threadbit_test') . '";');
Hook: showthread_complete

Freesteyelz
09-30-2007, 09:37 PM
Thanks for replying Dismounted. :)

I've implemented the hook in showthread_complete as described above but the $threadbit content did not display in $threadbit_test. I could be wrong but isn't $threadbit called from the forumdisplay hook?

Still, I tried forumdisplay_start and forumdisplay_complete hooks but to no avail either. Hmm...

--------------- Added at 12:45 ---------------

Update:

I changed the hook to "threadbit_display" and the content showed up. :up: The downside is that $threadbit_test added border lines that $threabit template did not. At least I'm getting closer. :)