Question
Is there a way to make changes to the template from a plugin? I'm trying to modify
SlideShowPlugin to work with Eric Meyer's
S5 stuff.
The only thing remaining is that I need to substitute %SLIDESHOWTITLE% and %SLIDESHOWDATE% in the template,
view.s5.tmpl. This falls outside the %TEXT% portion of the template (which is the only thing visible to
commonTagsHandler).
Please tell me that I can do this somehow.
Environment
--
PankajPant - 14 Sep 2005
Answer
If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list below the edit box.
Upon further inspection, it seems that
handleCommonTags is called on the text first and then on the template itself. The title, etc. is being set from the arguements of %SLIDESHOWSTART{}% So, I just need to figure out how to "remember" the data between the two calls.
--
PankajPant - 14 Sep 2005
This is a strage coincidence: I was ranting just yesterday on
TWikiIRC that we need a way to modify templates programatically in an easy way
If you plan to do this on Dakar, there is a way to remember the text between calls: Store the information you want in $session (ie: $session->{SlideShowPlugin}{somedata} ). As there is one session per client being server, there won't be any mixup. Also, check out if you can use the contexts to determine what's being rendered.
Again, this works only on Dakar. For Cairo I think you'll need to rely on globals.
hope this helps
--
RafaelAlvarez - 14 Sep 2005
I need this for Cairo. Could you provide some more information on "rely on globals"? Even a pointer to a another plugin that does something similar would help.
Thanks.
--
PankajPant - 14 Sep 2005
I mean, use a global variable to store the information between calls.
--
RafaelAlvarez - 14 Sep 2005
Sigh ... after fighting for over two hours, I finally figured out why the variables in the template were not getting expanded.
SlideShowPlugin::commonTagsHandler() has this condition:
if ($_[0] =~ /%SLIDESHOWSTART/) {
$_[0] = slideShowHandler ($_[0], $_[2], $_[1]);
}
which, off course, doesn't let the template through. Once, I relaxed this condition a bit, things started working like a charm.
--
PankajPant - 15 Sep 2005
Good that this worked out. Notice that you will have a slight performance impact for topics that do not have a slideshow.
--
PeterThoeny - 15 Sep 2005
Well, I didn't remove it completely. It looks for SLIDESHOWSTART or SLIDESHOWTITLE (the second is in the template to set the
<title> field).
--
PankajPant - 15 Sep 2005