Tags:
create new tag
view all tags

SID-00046: Use of context="header_text" in templates

Status: Answered Answered TWiki version: 4.2.1 Perl version: 5.6.1
Category: CategoryRendering Server OS: Linux 2.6.9-34.0.1.0.11.ELsmp Last update: 17 years ago

I am using the standard pattern skin. I have the standard set of buttons at the top of the view page and a longer set at the bottom. My wish is to not set access keys on the buttons that appear at the top. For me these are Edit, Attach, Printable. To do this I have my own copy of the template viewtopicactionbuttons. I am just trying to fix the Edit button presently. I have set the template up with;

%TMPL:DEF{"edit_topic_link_ak"}%<span class="patternButton"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=1232465691%TMPL:P{"url_param_editaction"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edith"}%</a></span>%TMPL:END%

%TMPL:DEF{"edit_topic_link_nak"}%<span class="patternButton"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=1232465691%TMPL:P{"url_param_editaction"}%' rel='nofollow' %MAKETEXT{"title='Edit this topic text'>Edith"}%</a></span>%TMPL:END%

%TMPL:DEF{"edit_topic_link"}%%TMPL:P{context="header_text" then="edit_topic_link_nak" else="edit_topic_link_ak"}%%TMPL:END%
to replace the corresponding part of the shipped template. My template is being picked up (I added an "h" to the label text Edit which shows up when I add the ?cover=name to the view URL).

The problem is that the condition always evaluates to false so I end up adding the access key. I expect that I just can not use context="header/body/footer_text" at this point but I don't see why not from the doc I've read. Any insight would be appreciated.

-- IanNeall - 20 Jan 2009

Discussion and Answer

The context stuff is relatively new and is documented at IfStatements.

Reading the code of twiki/lib/TWiki/UI/View.pm, the context="header_text" is set for the header. The header is the stuff "above" the actual page text defined by %TEXT%, the footer the "stuff" after it. In the most simplified form, a skin may contain this:

<html>
<body>
<!-- this is context="header_text"-->
%TEXT%
<!-- this is context="footer_text"-->
</body>
</html>

Possible cause for context not picking up the header section:

1. Wrong timing in rendering pipeline. TWiki renders text in several steps. The %TMPL:P{context="header_text" ...}% might be too early? You can test with an %IF{...}% between the %TMPL:P{}% and %TMPL:END%. (I find this less likely the cause.)

2. The skin might re-order screen elements with CSS. For example, the skin might render the main page body first, followed by the page decoration (including header part). That is, even though the header is visually above the main text, by context it is after the %TEXT%. I believe this is the case for the PatternSkin.

Fix: You could $SET() a SpreadSheetPlugin variable at the right place in the skin to indicate that you are entering the top button bar, and use $GET() to do the conditional stuff deep down in the skin hierarchy.

-- PeterThoeny - 21 Jan 2009

Thanks Peter. The fix works fine. Here are the details.

Template viewtoolbar.pattern.tmpl now contains;

...
%TMPL:DEF{"toolbar"}%
<div class="patternTop"> %CALC{"$SET(WikiRenderTop,1)"}%
<div class="patternToolBar">
%TMPL:P{"toolbar_buttons"}%
</div><!-- /patternToolBar-->
<div class="patternToolBarBottom"></div> %CALC{"$SET(WikiRenderTop,0)"}%
</div><!-- /patternTop-->%TMPL:END%

and the template viewtopicactionbuttons.pattern.tmpl contains;

%TMPL:DEF{"edit_topic_link"}%<span class="patternButton"><a href='%SCRIPTURL{"edit"}%/%WEB%/%TOPIC%?t=%GMTIME{"$epoch"}%%TMPL:P{"url_param_editaction"}%' rel='nofollow'  %CALC{"$IF($GET(WikiRenderTop)==0, %MAKETEXT{"title='Edit this topic text' accesskey='e'>&Edit"}%, %MAKETEXT{"title='Edit this topic text'>Edit"}%)"}%</a></span>%TMPL:END%

-- IanNeall - 21 Jan 2009

I am glad it worked out. Thanks for posting the solutions so that other TWiki community members can learn!

-- PeterThoeny - 21 Jan 2009

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
SupportForm
Status Answered
Title Use of context="header_text" in templates
SupportCategory CategoryRendering
TWiki version 4.2.1
Server OS Linux 2.6.9-34.0.1.0.11.ELsmp
Web server Oracle-Application-Server-10g/10.1.2.0.2
Perl version 5.6.1
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2009-01-21 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.