Re: [Radiant] access one specific child

2007-04-23 Thread Erik van Oosten
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/

___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] access one specific child

2007-04-22 Thread Raphael Bauduin
On 4/20/07, Oliver Baltzer [EMAIL PROTECTED] wrote:
 Raphael Bauduin wrote:
  is there a way to select one specific child, in contrast to iterating
  over all of them?
  Something like children:each slug=child-slug or child 
  slug=child-slug.

 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


Exactly what I needed!

Will this patch be applied to the svn repo?

Thanks

Raph



 Cheers,
 Oliver
 ___
 Radiant mailing list
 Post:   Radiant@lists.radiantcms.org
 Search: http://radiantcms.org/mailing-list/search/
 Site:   http://lists.radiantcms.org/mailman/listinfo/radiant



-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


[Radiant] access one specific child

2007-04-20 Thread Raphael Bauduin
Hi,

is there a way to select one specific child, in contrast to iterating
over all of them?
Something like children:each slug=child-slug or child slug=child-slug.

thanks

Raph

-- 
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] access one specific child

2007-04-20 Thread Farrel Lifson
On 20/04/07, Raphael Bauduin [EMAIL PROTECTED] wrote:
 Hi,

 is there a way to select one specific child, in contrast to iterating
 over all of them?
 Something like children:each slug=child-slug or child slug=child-slug.


r:find url=/path/to/child
...
/r:find

Farrel
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] access one specific child

2007-04-20 Thread Oliver Baltzer
Raphael Bauduin wrote:
 is there a way to select one specific child, in contrast to iterating
 over all of them?
 Something like children:each slug=child-slug or child slug=child-slug.

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
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant