[Radiant] if_content with inherit

Jim Gay jim at saturnflyer.com
Tue Jul 8 11:16:04 CDT 2008


This
<r:if_content part="this, that">Stuff</r:if_content>
is already implemented for the next version and I think is best served  
as a shortcut for your
<r:if_content part="this"><r:if_content part="that">Stuff</ 
r:if_content></r:if_content>

I added a similar feature to the radiant-tags-extension (http://github.com/jomz/radiant-tags-extension/tree/master 
) to what you are suggesting.
In that extension you can tag pages and then loop through all pages  
with the given tags
<r:tagged with="this that other">
I added a 'with_any' option to search for pages with any of the given  
tags
<r:tagged with="this that other" with_any="true">

I would opt for something like that for if_content.
For a non-core tag I think that 'with_any' is fine, but I don't  
believe any of the other standard tags have underscored attribute  
names, so I'd be inclined to maintain the status quo and do something  
like:

<r:if_content part="this, that" any="true">

Or better yet
<r:if_content part="this, that" collect="all"> #this being the default
<r:if_content part="this, that" collect="any">
Or
<r:if_content part="this, that" find="all"> #this being the default
<r:if_content part="this, that" find="any">

But this is a tangent. I think your point about the behavior of
<r:if_content part="this, that" inherit="true"> <r:content part="this"  
inherit="true" /><r:content part="that" inherit="true" /></r:if_content>
is a good one.

Likewise, I've added inherit to r:unless_content.

On Jul 8, 2008, at 11:16 AM, Adam van den Hoven wrote:

> Actually I think you need to rethink things a bit. Specifically, I  
> think that specifying multiple parts should be handled in an OR  
> fashion. The reason is that there would  be no way to create a  
> div.sidebar if either a marketing or callout part exist and then put  
> one or both of those part into the div. This is a completely  
> reasonable use case (IMHO). At the same time, you can preserve the  
> AND behaviour by nesting <r:if_content> tags.
>
> As you've proposed, I can see no difference between:
>
> <r:if_content part="this, that">Stuff</r:if_content>
>
> and
>
> <r:if_content part="this"><r:if_content part="that">Stuff</ 
> r:if_content></r:if_content>
>
> And that suggests to me that applying an OR to the first case is a  
> useful idea.
>
> As to how inherit should work, I think you're on the right track;  
> look for each part independently. Otherwise the following would not  
> behave as you'd expect:
>
> <r:if_content part="this, that" inherit="true"> <r:content  
> part="this" inherit="true" /><r:content part="that" inherit="true" / 
> ></r:if_content>
>
> Adam
>
> On 7-Jul-08, at 5:29 PM, Jim Gay wrote:
>
>> I'm working on this feature, but one of the main reasons I put this  
>> out to the list for feedback is that it can become confusing, so I  
>> wanted to see if anyone else had thought about this.
>>
>> The next version of Radiant (0.6.8) will accept a list of parts in  
>> if_content
>> <r:if_content part="this, that">
>> It will display the contents only if all of those parts exist.
>> This is useful for outputting information from customers (for  
>> example) where you want to display the customer description part  
>> only if it also has a testimonial part.
>> If only some but not all of the listed parts are found, it will  
>> display nothing.
>>
>> In light of that, how would you expect inherit="true" to work?
>>
>> Would you expect that it looks up the tree for the existence of  
>> each part no matter where in the tree that part is found?
>> Or would you expect it to look up the tree to find any page that  
>> has all of the listed parts?
>>
>> My inclination is to make it look up the tree for each listed part  
>> regardless of the location of other parts, and as long as it finds  
>> all of them, it will output the contents of the if_content tag.
>>
>> I personally have had the need for
>> <r:if_content part="this, that">
>> <r:if_content part="this" inherit="true">
>>
>> But I have not had the real-world need for
>> <r:if_content part="this, that" inherit="true">
>>
>> I'm working on it slowly to allow myself time to consider the pros  
>> and cons and to allow anyone to jump in with ideas before I get too  
>> far. I'd appreciate more feedback.
>> On Jul 7, 2008, at 7:04 PM, Adam van den Hoven wrote:
>>
>>> There are few things that make me more grumpy that empty elements  
>>> that server no useful purpose.  I'd love it.
>>> On 7-Jul-08, at 12:56 PM, Jim Gay wrote:
>>>
>>>> Is there any interest in adding the inherit attribute to the  
>>>> if_content tag?
>>>>
>>>> In some instances I'll find the need to output something like
>>>>
>>>> <div id="extras">
>>>> <r:content part="extras" inherit="true" />
>>>> </div>
>>>>
>>>> But I don't have a way to conditionally render the <div  
>>>> id="extras"> bit.
>>>> If the parent or current page has an "extras" part, then it will  
>>>> appear, but if it doesn't I'll have an empty div element.
>>>>
>>>> Is there a simple way to handle this or would <r:if_content  
>>>> inherit="true"> be a clear and welcomed addition?
>>>>
>>>> -Jim
>> _______________________________________________
>> Radiant mailing list
>> Post:   Radiant at radiantcms.org
>> Search: http://radiantcms.org/mailing-list/search/
>> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant at radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant



More information about the Radiant mailing list