We have a requirement to output some of an XOWiki output under a separate (read-only) template via a .vuh file. I started off using an <include src="/packages/xowiki/lib/view" url="@url@" template_file="view-links"> but this doesn't quite have the desired effect as I can't access the page title from it. So I've implemented my own version of the view template in /content/index.vuh as follows:
ad_page_contract {
Return a CMS page
under the /content/ url
from XOWiki mounted as /cms/
} {
{css "<link rel='stylesheet' type='text/css' href='/resources/xowiki/xowiki.css' media='all' >\n"}
}
# Get the required page name
set url "/cms/[ad_conn path_info]"
# Setup the XOWiki params
set parameter [subst {
{-m view}
{-template_file "fd-view-links"}
{-folder_id 0}
}]
# Get the XOWiki content
::xowiki::Package initialize -parameter $parameter -url $url
set page [::$package_id invoke -method $m]
set title [lindex $page 0]
set html [lindex $page 1]
# Add the css link to the html
set html "${css}${html}"
# Correct the links (cms=content)
regsub -all {/cms/} $html {/content/} html
# Redirect to the viewing template
rp_form_put html $html
rp_form_put title $title
rp_internal_redirect view.adp
This uses a modified adp template file which returns the title and html as two parts of a list:
{@title@} {<div class='xowiki-content'>@content;noquote@</div>}
The two parts are then fed to an internal redirect (view.adp) which renders the output using the alternate template.
I'm wondering if there is a better (simpler) way to achieve the same i.e server page title and content via a VUH at /content/ from an XOWiki mounted at /cms/?
Thoughts gratefully received
- Steve