Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Injecting Out of Order Code

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
smarty_user
Smarty n00b


Joined: 11 Sep 2003
Posts: 4

PostPosted: Mon Feb 14, 2005 2:18 am    Post subject: Injecting Out of Order Code Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Feb 14, 2005 6:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP