On Jun 17, 2008, at 8:16 PM, nn wrote:

Hi Jim,

Thanks for the reply.

On Tue, Jun 17, 2008 at 1:18 PM, Jim Gay <[EMAIL PROTECTED]> wrote:
You'd need to write a tag that wraps it.

tag 'myext:model:if_something' do |tag|
tag.expand if (your code to check that value)
end

that would expand the tag only if that something is set the way you want,
and your radius/html would look like this:

<r:myext:model:if_something>
h1. Some Header

<r:myext:model:something />
</r:myext:model:if_something>

There are probably other ways to do it too, but that's the simplest one that
comes to mind.

I was a bit hasty, sorry about that. The problem is slightly different:

 <div class="item">
   <h1>Some Header</h1>
   <ul>
   <r:item:each param="some value">
     <li><a href="/some/url/#{item.id}"><r:item.attrib1 />
<r:item.attrib2 /></a></li>
   </r:item:each>
   </ul>
 </div>

 <div class="item">
   <h1>Another Header</h1>
   <ul>
   <r:item:each param="another value">
     <li><a href="/some/url/#{item.id}"><r:item.attrib1 />
<r:item.attrib2 /></a></li>
   </r:item:each>
   </ul>
 </div>

where <r:item:each> returns the items from the database by param's
value. I'd like to wrap the header so that it shows only if there is
something to be shown in the list under it (inside the div). I haven't
been able to figure it out, and the best I've managed to do so far is
to repeatedly show the content I want to wrap (like its multiplied by
the list size).

I'm having trouble understanding exactly what you want, but does this make sense:

<r:items param="value">
 <div class="item">
   <h1>Some Header</h1>
   <ul>
   <r:each>
<li><a href="/some/url/<r:id />"><r:attrib1 /><r:attrib2 /></a></ li>
   </r:each>
   </ul>
 </div>
</r:items>

You can create the scope for the block that you want to show conditionally, but you need to put the condition on some container of the header if you want the header to be shown or not based on that condition. I don't know what you're doing, but the plural items just seems more clear to me.

In order to do the above you'll need to create tags like this

tag 'items' do |tag|
tag.expand if (the items count is greater than 0 based on the provided param value)
end

tag 'items:each' do |tag|
  #loop through the items
end

tag 'items:each:id' do |tag|
  #print the id
end

tag 'items:each:attrib1' do |tag|
  #print attrib1
end

tag 'items:each:attrib2' do |tag|
  #print attrib2
end
_______________________________________________
Radiant mailing list
Post:   [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to