Forum OpenACS Development: Alternate Template for XOWiki Output

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

Collapse
Posted by Gustaf Neumann on
Is there any reason why you have not replaced the template-file "view-links" in
<include src="/packages/xowiki/lib/view" url="@url@" template_file="view-links">
with something fitting your needs? Within the adp/tcl pair you have access to all variables. 
Collapse
Posted by Steve Manning on
Hi Gustaf

Thats why I thought I'd ask - I knew there would be a simpler method :o)

I was trying to pass back to the master template from the template in /content/ and of course there is no easy method to do this. But of course I can just create a page consisting of only the <include> then handle the templates from an adp in /xowiki/www/. I've had to modify the view.tcl in /xowiki/lib to substitute the /cms/ links with /content/ but otherwise that works a treat.

So now I have /content/index.vuh with just:

    rp_form_put url "/cms/[ad_conn path_info]"
    rp_internal_redirect template.adp
feeding /content/template.adp with just the include:
    <include src="/packages/xowiki/lib/ext-view" url="@url@" template_file="fd-external-view">
That calls the modified view.tcl/adp pair in the /xowiki/lib which render the page using the template fd-external-view.adp in /xowiki/www.

Simple.