Recursive <children:each>

I wanted to generate a sitemap for my radiant powered site and used this
code:

Unfortunately it doesn’t work since r:children_each is non recursive.
Anyone
has an idea on how to make it recursive?

Giovanni -

I would first create a global tag, using any one of the methods
previously
discussed on the mailing list. The tag would be defined like so:

tag “if_children” do |tag|
tag.expand if tag.locals.page.has_children?
end

Then I would create a snippet that is similar to yours called “sitemap”:

<r:children:each>

  • In the page that I want the sitemap I would do this (the find tag is
    optional, depending on where you want the sitemap to start):
    <r:find url="/>

    Good luck!

    Sean C.
    seancribbs.com

    Thanks, that kind of recursion what was I looking for. Actually you
    don’t
    even need the if_children tag since <r:children:each> won’t execute if
    there
    are no children.

    2006/9/14, Sean C. [email protected]:

    This is the final code I used.

    In the sitemap page:

    The sitemapper snippet:

    <r:children:each>
    <r:unless_content part=“no-map”>


  • <r:link />

      <r:snippet name=“sitemapper” />


  • </r:unless_content>
    </r:children:each>

    2006/9/14, Sean C. [email protected]:

    On 14/09/06, Giovanni I. [email protected] wrote:

    This is the final code I used.

    Thanks for posting this!

    I’ve updated the wiki’s HowTo section with a ‘Recipies’ section, as
    discussed on list last week, and made this the first one! :slight_smile:

    http://dev.radiantcms.org/radiant/wiki/HowToMakeASiteMap

    The only significant change is that I made use of

    <r:children:each by=“title” order=“asc”>

    as otherwise the sitemap is ordered by Radiant’s page id numbers so
    the first page in the sitelist is the first page created


    Regards,
    Dave

    2006/9/14, Dave C. [email protected]:

    On 14/09/06, Giovanni I. [email protected] wrote:

    This is the final code I used.

    Thanks for posting this!

    I’ve updated the wiki’s HowTo section with a ‘Recipies’ section, as
    discussed on list last week, and made this the first one! :slight_smile:

    http://dev.radiantcms.org/radiant/wiki/HowToMakeASiteMap

    Well it’s a honor to be the first there :slight_smile:

    The only significant change is that I made use of

    <r:children:each by=“title” order=“asc”>

    as otherwise the sitemap is ordered by Radiant’s page id numbers so
    the first page in the sitelist is the first page created

    I was sure I was using by=“title” :slight_smile:

    – Giovanni

    Nicely done, Giovanni and Dave.

    Sean C.
    seancribbs.com