# Avoid Stylesheet Children

**URL:** <https://www.ruby-forum.com/t/avoid-stylesheet-children/111073>\
**Category:** Radiant CMS\
**Created:** [August 2, 2007, 11:33am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073 "2007-08-02T11:33:27Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 2, 2007, 11:33am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/1 "2007-08-02T11:33:27Z")

</div>

Hi Everyone,

After being away for a while, I’m now taking a few days to play with  
Radiant again in the hope of migrating one of my static sites to  
Radiant. In my ‘Hello World’ example that I uploaded as a tutorial, I  
created a stylesheet as a child of the main page and then used that for  
styling the main page as well as any of its children.

Now, I’ve run into this problem. If I try to iterate through the  
children of the main page to create a list of links to the children, it  
obviously also creates a link to the stylesheet. I’m sure that there is  
a simple way to avoid it, but I think I’m too green just yet. 😑

Thanks for the help.

Cheers,  
Mohit.  
8/2/2007 | 5:32 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 2, 2007, 11:41am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/2 "2007-08-02T11:41:30Z")

</div>

Hi,

I always overcome this problem by adding an empty page part to the  
stylesheet. By using the \<r:unless\_content part=“no\_menu”\> tag you  
can determine which pages should be added to the main menu.

Edwin

Op 2-aug-2007, om 11:32 heeft Mohit S. het volgende geschreven:

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 2, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/3 "2007-08-02T19:08:48Z")

</div>

Hi Edwin,

Thank you for the suggestion. I’m still new to the tags in Radiant, but  
I shall keep a lookout for the unless\_content tag.

I’m still a bit confused about how to use your suggestion, but I’ll try  
a few things and hopefully stumble on the correct meaning! 🙂

Cheers  
Mohit.

Edwin Vlieg wrote:

> > Hi Everyone,  
> > a simple way to avoid it, but I think I’m too green just yet. 😑
> > 
> > Thanks for the help.
> > 
> > Cheers,  
> > Mohit.  
> > 8/2/2007 | 5:32 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 8:31am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/4 "2007-08-03T08:31:08Z")

</div>

Thanks Keymone,

I have my work cut out for the weekend now. I think this will also give  
me the chance to try out adding a Rails model to a Radiant site  
(something I haven’t yet done).

Do I create the model in the same way as a regular Rails app? In the  
root of the Radiant directory, I just go  
[#]script\generate model …

Thanks for your help.

Cheers,  
Mohit.  
8/3/2007 | 2:27 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 8:22am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/5 "2007-08-03T08:22:07Z")

</div>

maybe there is a reason to implement page properties?  
using page parts for that can cause huge overhead

it’s better (and more obvious) to type  
\<r:if\_content property=“hide from menu”\> \</r:if\_content\>

on rails side you only have to add Property model  
and give Page has\_many :properties

there will be “properties” tab on page edit and user should be  
able to add properties specifying property name and property  
value. to improve performance of SQL queries properties can  
also have type attribute e.g. int, string, date and properties  
inheritance between pages.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 8:55am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/6 "2007-08-03T08:55:13Z")

</div>

Hi Keith

Thanks for the suggestion and the link. I’ve seen the tutorial for the  
extension before and I think it has incredible detail on how to go about  
doing something like this. So, I shall follow that through and as for  
advice again if I run into something.

Cheers  
Mohit.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 8:35am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/7 "2007-08-03T08:35:08Z")

</div>

I would do this in an extension. John has a very nice tutorial at  
[http://www.radiantcms.org/blog/archives/2007/06/23/tutorial-creating-](http://www.radiantcms.org/blog/archives/2007/06/23/tutorial-creating-)  
radiant-extensions/  
This should get you going. In short, radiant has extension generators  
that work like the normal rails generators.

Keith B.  
removed\_email\_address@domain.invalid  
Tel: +49-7731-7983830

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 11:05am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/8 "2007-08-03T11:05:34Z")

</div>

Hi Mihot,

You could have a look at the page attributes tag, I think that does  
the trick 🙂

[http://wiki.radiantcms.org/Thirdparty\_Extensions](http://wiki.radiantcms.org/Thirdparty_Extensions)

Edwin

Op 3-aug-2007, om 11:01 heeft Mohit S. het volgende geschreven:

> know how to add properties to specific pages :-S (the extensions
> 
> > > generators
> > > 
> > > > [#]script\generate model …
> > > > 
> > > > > maybe there is a reason to implement page properties?  
> > > > > value. to improve performance of SQL queries properties can  
> > > > > Radiant, but  
> > > > > Edwin Vlieg wrote:
> > > > > 
> > > > > > 
> > > > > 
> > > > > ```
> > > > > with
> > > > > 
> > > > > ```
> > > > > 
> > > > > > > styling the main page as well as any of its children.
> > > > > 
> > > > > ```
> > > > > _______________________________________________
> > > > > 
> > > > > ```
> > > > > 
> > > > > Regards, Keymone
> 
> * * *
> 
> Radiant mailing list  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

»  
» Flydesign.nl - Webdevelopment & hosting  
» www.flydesign.nl - 06 4147 5537  
»

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 11:02am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/9 "2007-08-03T11:02:33Z")

</div>

Hi Everyone,

I used Edwin’s suggestion to overcome the problem by adding an empty  
page part to the stylesheet and then using the \<r:unless\_content  
part=“no\_menu”\> tag to determine which pages should be added to the main  
menu. That works fine.

I also followed the extensions tutorial to create an extension that  
allows you to create properties. That portion works, but I don’t yet  
know how to add properties to specific pages :-S (the extensions  
tutorial doesn’t work on per-page properties) so I’m not yet sure how to  
go about it. But I hope that I’ll find out some more by looking at some  
other extensions.

Cheers,  
Mohit.  
8/3/2007 | 4:59 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 11:20am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/10 "2007-08-03T11:20:38Z")

</div>

Thanks again Edwin & Keith.

Cheers,  
Mohit.  
8/3/2007 | 5:18 PM.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [January 25, 2008, 9:09am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/11 "2008-01-25T09:09:18Z")

</div>

Mohit S. wrote:

> In my ‘Hello World’ example that I uploaded as a tutorial, I  
> created a stylesheet as a child of the main page and then used that for  
> styling the main page as well as any of its children.
> 
> Now, I’ve run into this problem. If I try to iterate through the  
> children of the main page to create a list of links to the children, it  
> obviously also creates a link to the stylesheet.

Override the r:children tags. Using the tags’ option hash, join the  
layouts table and add a condition "layouts.content\_type != ‘text/css’.

To only get children which are normal pages, the conditions should be  
something like “pages.class\_name = ‘page’ and (layouts.content\_type = ‘’  
or layouts.content\_type is null)”.

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [August 3, 2007, 11:13am UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/12 "2007-08-03T11:13:37Z")

</div>

Unfortunately, this is not an extension, but a pretty major hack of a  
branch… might be a nice starting point though.

Keith B.  
Tel: +49-7731-7983830  
removed\_email\_address@domain.invalid  
[http://keithbingman.com](http://keithbingman.com)

---

<div class="post-metadata">

**Author:** ![mohits](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/bbe5ce/32.png) [@mohits](https://www.ruby-forum.com/u/mohits)\
**Post date:** [January 28, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/avoid-stylesheet-children/111073/13 "2008-01-28T16:35:24Z")

</div>

Witter Cheng wrote:

> Override the r:children tags. Using the tags’ option hash, join the  
> layouts table and add a condition "layouts.content\_type != ‘text/css’.
> 
> To only get children which are normal pages, the conditions should be  
> something like “pages.class\_name = ‘page’ and (layouts.content\_type = ‘’  
> or layouts.content\_type is null)”.

Wow, that’s really a blast from the past! I switched to using a  
‘no\_menu’ page part - just add a page part called ‘no\_menu’ to any page  
that needs to be skipped… and then use that as part of the condition.

Thanks for the response, though!

Cheers,  
Mohit.  
1/28/2008 | 11:35 PM.
