[Radiant] access one specific child

Erik van Oosten e.vanoosten at chello.nl
Mon Apr 23 01:37:45 CDT 2007


Hi Oliver,

Perhaps this should be added to Radiant's Trac.
I would welcome this patch as well.

Regards,
     Erik.


Oliver Baltzer wrote:
> I have made a little patch for that to find a URL locally relative to 
> the current page:
>
> --- standard_tags.rb    (revision 363)
> +++ standard_tags.rb    (working copy)
> @@ -396,9 +398,12 @@
>     }
>     tag 'find' do |tag|
>       if url = tag.attr['url']
> -      if found = Page.find_by_url(tag.attr['url'])
> +      if url[0..0] != "/" and found = Content.find(:first, :conditions 
> => ["slug = ? AND parent_id = ?", url, tag.locals.page.id])
>           tag.locals.page = found
>           tag.expand
> +      elsif found = Page.find_by_url(tag.attr['url'])
> +        tag.locals.page = found
> +        tag.expand
>         end
>       else
>         raise TagError.new("`find' tag must contain `url' attribute")
>
> You just use it like find: <r:find url="slug">...</r:find>
>
> Cheers,
> Oliver
>
>   

-- 
Erik van Oosten
http://www.day-to-day-stuff.blogspot.com/




More information about the Radiant mailing list