We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
You are here: TWiki> Support Web>OverridePageTitle (26 Jul 2007, VickiBrown)
Tags:
create new tag
, view all tags

Question

By default, TWiki puts (a slightly modified version of) the breadcrumb path into the web page title.

Is there a way I can override this? (if not, I'll file an enhancement request).

When doing TWiki applications, I end up with pages whose names are, effectively, database keys. e.g.: ProjectDetail200707p2

I want to set the paage Title to show something... easier for the human reader to grok.

Environment

TWiki version: unspecified
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Missing functionality

-- VickiBrown - 12 Jul 2007

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.

Create a subskin template and override %TMPL:DEF{"windowtitle"}%.

-- ArthurClemens - 12 Jul 2007

Interesting suggestion... unfortunately, I don't think that will scale. unless there's a way to test if a variable is defined usng TWiki TMPL language? This would have to be conditional, based on a toggle switch. (19 times out of 20, I do want the default behaviour).

that is, given constants.pattern.tmpl

%TMPL:DEF{"windowtitle"}%<title>%TMPL:P{"titleaction"}% <nop>%TOPIC% ... %WEB%  ... %TMPL:END%

if, say, var PREFTITLE is set, I'd want to use that. Otherwise, I'd want to use TOPIC as usual.

-- VickiBrown - 13 Jul 2007

The approach we used with one client, to do exactly what you are asking for, was to provide a customised plugin that post-processed the output of the BreadCrumbsPlugin. The plugin recognised database keys in the breadcrumb and converted them to a "friendly" representation.

-- CrawfordCurrie - 13 Jul 2007

This could work (untested):

%TMPL:DEF{"normalwindowtitle"}%<title>%TMPL:P{"titleaction"}% <nop>%TOPIC% %TMPL:P{"titlesep"}% %WEB% %TMPL:P{"titlesep"}% <nop>%WIKITOOLNAME%</title>%TMPL:END%

%TMPL:DEF{"dbwindowtitle"}%<title><nop>%PREFTITLE% %TMPL:P{"titlesep"}% %WEB% %TMPL:P{"titlesep"}% <nop>%WIKITOOLNAME%</title>%TMPL:END%

%TMPL:DEF{"windowtitle"}%%TMPL:P{"defined PREFTITLE" then="dbwindowtitle" else ="normalwindowtitle"}%%TMPL:END%

-- ArthurClemens - 13 Jul 2007

I'm having some difficulty making the above work (though I like it). However, in trying to find an example of using "defined" I tripped over Codev.CustomPageTitle. The latter didn't have the elegance of Arthur's pair of DEFs but did work.

So I played with Arthurs code and found whhat was missing

%TMPL:DEF{"normalwindowtitle"}%<title>%TMPL:P{"titleaction"}% <nop>%TOPIC% %TMPL:P{"titlesep"}% %WEB% %TMPL:P{"titlesep"}% <nop>%WIKITOOLNAME%</title>%TMPL:END%

%TMPL:DEF{"dbwindowtitle"}%<title><nop>%PREFTITLE% %TMPL:P{"titlesep"}% %WEB% %TMPL:P{"titlesep"}% <nop>%WIKITOOLNAME%</title>%TMPL:END%

%TMPL:DEF{"windowtitle"}%%TMPL:P{"titleaction"}%%IF{"defined PREFTITLE" then="%TMPL:P{"dbwindowtitle"}%" else="%TMPL:P{"normalwindowtitle"}%"}%%TMPL:END%

(see also Codev.CustomPageTitle for the one-line solution

-- VickiBrown - 13 Jul 2007


I'm back with a slightly morphed problem. It almost works. SO very close and yet so befuddlingly far away.

The cover is working perfectly. If I put

   * Set PAGETITLE = Vicki Loves Bagels
into a page, the page title changes as expected. Tra la.

However, if I put

<!--
   * Set PAGETITLE = %IFDEFINED{"%FORMFIELD{"ProjectName"}%" then="%FORMFIELD{"ProjectName"}%" else="%TOPIC%"}%
-->

into the page, the Page Title becomes

%IFDEFINED{

Aargh.

I call this a bug Item4414 filed. Is there a workaround?

-- VickiBrown - 26 Jul 2007

I don't think this is a bug. Did you try to escape the % by using <nop> ?

Don't know which % needs to be escaped but quiet often something does not work because of nested variables and the way they are processed.

-- CarloSchulz - 26 Jul 2007

When the variable in the page has a different value from the same variable in the title, that violates the Principle of Least Astonishment. That qualifies as a bug.

(if I couldn't set any variable as shown, that would be a misunderstanding or a syntax error. But I can set the variable and it evaluates as expected... everywhere except the page title. That's a bug.)

FWIW, my workaround, which I've decided is actually better in this case, is the simpler

<!--
   * Set PAGETITLE = %FORMFIELD{"ProjectName"}% %TOPIC%
-->

-- VickiBrown - 26 Jul 2007

 
Change status to:
Topic revision: r9 - 26 Jul 2007 - 16:04:19 - VickiBrown
 
TWIKI.NET
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