Forum OpenACS Development: Re: template::head::add_meta in XoWiki

Collapse
Posted by Torben Brosten on

Dennis Lima,

This has been a frustrating issue for me, too.

The way I have worked around it is to not set any default meta tags on any page. That way, only specific tags are set. Then, at the end of the blank-master.tcl file, I set defaults using a custom proc: template::head::defaults_meta like so:

template::head::defaults_meta -name description -content "[ad_system_name]: $doc(title)"
template::head::defaults_meta -name keywords -content "[ad_conn instance_name]"
template::head::defaults_meta -name Robots -content "INDEX,FOLLOW"

Here is the proc added to packages/acs-templating/tcl/head-procs.tcl

 ad_proc -public template::head::defaults_meta {
     {-http_equiv ""}
     {-name ""}
     {-scheme ""}
     {-content ""}
     {-lang ""}
 } {
     Add a meta tag to the head section of the document to be returned to the
     users client if the meta tag does not yet exist.
     Either name or http_equiv must be supplied.
 
     @param http_equiv the http-equiv attribute of the meta tag, ie. the 
                       HTTP header which this metadata is equivalent to
                       eg. 'content-type'
     @param name       the name attribute of the meta tag, ie. the metadata 
                       identifier
     @param scheme     the scheme attribute of the meta tag defining which 
                       metadata scheme should be used to interpret the metadata, 
                       eg. 'DC' for Dublin Core (http://dublincore.org/)
     @param content    the content attribute of the meta tag, ie the metadata
                       value
     @param lang       the lang attribute of the meta tag specifying the language 
                       of its attributes if they differ from the document language
 } {
     variable ::template::head::metas
 
     if {$http_equiv eq "" && $name eq ""} {
         error "You must supply either -http_equiv or -name."
     }
     if { ![info exists metas($http_equiv,$name) ] } {
         set metas($http_equiv,$name) [list \
         $http_equiv \
         $name \
         $scheme \
         $content \
         $lang \
         ]
     }
 }

Hope this helps,
cheers,
Torben

Collapse
Posted by Dennis Lima on
Thanks Torben -
This is good info. My problem is that I cannot find where particular meta values (specifically, -name keywords) are being set upstream (and it is not for lack of trying). Any insights on how to 'unset' these values?
Collapse
Posted by Gustaf Neumann on
Dennis, my understanding was that you wanted to change some default values of some meta tags from "templating" from within an xowiki page, while Torben recommendation was how to turn off the minimal setting of meta tags that xowiki does.

If i am right with my assumption, i can give you an explanation of what's going on. The question, which add_meta calls are effective are a matter of evaluation order. XoWiki renders the page, before the rendered output is passed to templating (the rendering code might influence, what templates are going to be used). So, if you set meta-tags from within xowiki, these can be easily overwritten by some surrounding templating code. So, the surrounding templating code should be defensive in not overwriting blindly the meta-tags. This is exactly what Torben's code does.

If you want to set keywords on a per-page basis in xowiki, you can do it e.g. via {{set-parameter keywords "XoWiki Wiki Documentation Handbook"}} as it is done on: http://alice.wu-wien.ac.at:8000/xowiki-doc/ . If you want to set the keywords on a per package instance basis, you could add a package parameter "keywords" and set it appropriately.

Hope this helps
-gustaf neumann

Collapse
Posted by Dennis Lima on
Bingo!

Works like a charm. Our content editors now have control of the meta keywords.
Thanks for your help.

(You too, Torben)