John W. Long wrote:

> This is a great idea. Please submit a patch.

Agreed. I can now do the following to have a heading that is itself a 
link to the parent page, in the manner of many Wiki engines:

  <h1>
    <r:parent><r:link><r:page><r:title /></r:page></r:link></r:parent>
  </h1>

However, this breaks horribly on the root page and in so doing reveals a 
small bug in the parent tag code. It needs this tweak:

  define_tag 'parent' do |tag|
    tag.locals.page = page.parent || page
    tag.expand
  end

Note the "|| page" on the second line.

Things get a bit hideous if we want to avoid having a link on the Home 
page in the heading, though, assuming you're using the construct above 
in a layout. Indenting things a bit to make it more legible, I've got 
this right now:

  <r:unless_url matches="^/$">
    <r:parent><r:link>
      <r:page><r:title /></r:page>
    </r:link></r:parent>
  </r:unless_url>
  <r:if_url matches="^/$">
    <r:title />
  </r:if_url>

Is there a more elegant approach?

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Radiant mailing list
[email protected]
http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to