r8 - 15 Sep 2005 - 13:28:03 - PankajPantYou are here: TWiki >  Support Web > ChangeTemplateFromPlugin
Tags:
, create new tag

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

TWiki version: TWikiRelease02Sep2004
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Plugins, Skin
-- PankajPant - 14 Sep 2005

Answer

ALERT! 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 smile

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

 
Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r8 < r7 < r6 < r5 < r4 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo