|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
smarty_user Smarty n00b
Joined: 11 Sep 2003 Posts: 4
|
Posted: Mon Feb 14, 2005 2:18 am Post subject: Injecting Out of Order Code |
|
|
I've written a plugin to create a vertical menu, and in so doing, it populates an array called $smarty->PreloadImages with the names of the images to preload on the page. I've written another plugin to create the body onload call with the image preloading. To wit:
Code: |
<body{onload}> {* note preload items consumed here *}
<div id="foo">
{vertmenu items=$bar} {* note preload items not known until here *}
</div>
...
|
However, onload must be called from within the body tag and the vertical menu plugin (being within the body) has not yet been called. My question is this: Does anyone know of a way to defer the expansion of a {} part of a template or to compose the page out of order in this fashion?
Thanks |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Feb 14, 2005 6:31 pm Post subject: |
|
|
This is never fun.
In your case, since you are populating an array, you have a way of knowing whether you need to insert code -- after the fact. You can exploit this knowledge via an output filter which, if it detects a populated array, would automatically find and rewrite the affected portion of the output. Not pretty, but it should work for you. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|