Children:each vs. navigation

Hi,

I’m building a site in radiant that has a section with a long
subnavigation
menu. Initially I built it like this:

<r:find url="/section/papers/">
<r:children:each by=“title”>


<r:link />


<r:content part=“shortline” />



</r:children:each>
</r:find>

That works fine, except that I need selected behaviour like r:navigation
has
so that I can add another class to the div class=entry to highlight the
sub
page the user is on.

I’ve tried using a big & nasty r:navigation tag (its a long list), but
the
problem in that case are the r:link & r:content bits referring to the
current page rather than the page I’m creating a link.

Is there any way to accomplish this with the basic tag set in radiant? I
can
imagine a few ways to modify the r:navigation or r:children:each tag
definitions, but that doesn’t really seem like a great way to go to me.
Am I
missing something obvious here?

Thanks,
Jim

Jim Herring wrote:

Hi,

I’m building a site in radiant that has a section with a long
subnavigation
menu. Initially I built it like this:

<r:find url="/section/papers/">
<r:children:each by=“title”>


<r:link />


<r:content part=“shortline” />



</r:children:each>
</r:find>

That works fine, except that I need selected behaviour like r:navigation
has
so that I can add another class to the div class=entry to highlight the
sub
page the user is on.

I’ve tried using a big & nasty r:navigation tag (its a long list), but
the
problem in that case are the r:link & r:content bits referring to the
current page rather than the page I’m creating a link.

Is there any way to accomplish this with the basic tag set in radiant? I
can
imagine a few ways to modify the r:navigation or r:children:each tag
definitions, but that doesn’t really seem like a great way to go to me.
Am I
missing something obvious here?

Thanks,
Jim

Jim,

I’ve read your message a couple times and don’t fully understand your
question.

This part in particualr is where I’m losing you:

the problem in that case are the r:link & r:content bits referring to
the current page rather than the page I’m creating a link.

Can you clarify this part and I might be able to help. I’m currently
implementing a site in Radiant which is requiring plent of
<r:navigation… tags and is crying for some more automated options that
still have some r:navigation style “selected” and “here” class tagging.

I’ve had good success creating some global tags and am working on a
couple of behaviors. Perhaps if I can understand what you’re after we
could collaborate on a new tag or two to meet both our needs.

Loren

Hi Loren,

I ended up solving this particular problem a different way, but the
original
issue is still a pain.

This part in particualr is where I’m losing you:

the problem in that case are the r:link & r:content bits referring to
the current page rather than the page I’m creating a link.

Can you clarify this part and I might be able to help. I’m currently
implementing a site in Radiant which is requiring plent of
<r:navigation… tags and is crying for some more automated options that
still have some r:navigation style “selected” and “here” class tagging.

Here is (I hope) a lucid description. What I found is that inside an
r:children:each tag, one has full access to each child’s data: title,
url,
link, slug, content, etc. The drawback with r:children:each is that the
ability to order and filter the child is, errr, rather primative. :slight_smile:

The navigation tag on the other hand allows complete manual control over
the
items looped over. The drawback is that inside a navigation tag one
doesn’t
actually have access to the pages being referred to. For example, here
is a
simple nav component for doodads. /doodads/ is the main doodad page, and
it
has perhaps 10 children, each of which is a different doodad detail page
(doodad-1, doodad-2, … doodad-n). The component is meant to be shown
on
the doodad overview and detail pages, and should highlight the doodad
page
we are on, if we are on a doodad detail page.

This works great as a snippet with one huge exception- the <r:content>
tags
refer to whatever page the user is looking at, not to the urls fed in by
the
navigation tag. I was wrong about the link tag not working here, it
does.

I ended up solving the problem using children:each and some css to get
around the lack of normal/here/selected tags. By setting the pages body
id="<r:slug />" and the div.item ids to each doodad’s r:slug it became
easy
to write CSS to “activate” any div.item whose id == body’s id.

body# #doodad-selector .item# { background-color: #ffc } body# #doodad-selector .item# h3 { color: #333 }

Doodad Nav

<r:children:each by="title">
  <r:link><div class="item" id="<r:slug />">
      <h3><r:title /></h3><r:content part="navline" /></div>
  </r:link>
</r:children:each>

</r:find>

That worked well for my purposes, but I would still love to have a
navigation tag that refers to actual pages rather than title/url pairs.
Or
maybe better would be an <r:foreach> tag which operates on a list of
pages
or the children of some page, and allows here / selected matching
inside.

All in all though Radiant has offered elegant solutions for most aspects
of
the site I’m building.

Jim

I want to organize old writings from the 1950s and sort them as articles
by date. I want to use a new content part titled ansi_date (19560417).
Is
there a way to sort the articles by my ansi_date content part using the
<r:children:each> tag?

[email protected] wrote:

I want to organize old writings from the 1950s and sort them as articles
by date. I want to use a new content part titled ansi_date (19560417). Is
there a way to sort the articles by my ansi_date content part using the
<r:children:each> tag?

Probably the best thing would be to manually update the articles
published_at date over the console or to write a script to do this for
you. The published_at field is the default order by field.


John L.
http://wiseheartdesign.com

Thanks for the attention John.

Being able to sort pages by content part would be a great feature. I’m
just starting with this so I’ve no clue on how to pull off something
like
that. But I’ll do what you’ve recommended.

Jose.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs