set custom skin for folder

9 messages Options
Embed this post
Permalink
Sverre Helge Bolstad () set custom skin for folder
Reply Threaded More More options
Print post
Permalink
Hi

I wish to set a different skin for a folder and all its subfolders. I  
have created a skin based on http://plone.org/products/diyplonestyle/ 
releases/1.0. And I have created an external method, an access rule  
and a python script based on http://plone.org/documentation/how-to/ 
set-skin-for-folder/.

The skin I have created works when I set it manually as the default  
skin. The select-skin based on access rule works fine if I choose  
Plone Tableless as the skin it should change to.

But it does work when I try to change to MySkin .. :(

Does anyone have a recipe for doing this in 2.1, or have anyone done  
something similar ?

A nice feature for the future would be to choose the skin for a  
folder from the "choose default view"  tab in the folder :)


br,
Sverre Helge Bolsted


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
dconvent () Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink
The easiest way to have a custom skin for a site section (folder and
subfolders) is to add a condition to the stylesheets registered with the
portal_css
For instance, you can use a condition like:

python:object.getPhysicalPath()[2]=='Members'

No need to setup access rules anymore  :-)

--
David

Sverre Helge Bolstad wrote:

> Hi
>
> I wish to set a different skin for a folder and all its subfolders. I  
> have created a skin based on http://plone.org/products/diyplonestyle/ 
> releases/1.0. And I have created an external method, an access rule  and
> a python script based on http://plone.org/documentation/how-to/ 
> set-skin-for-folder/.
>
> The skin I have created works when I set it manually as the default  
> skin. The select-skin based on access rule works fine if I choose  Plone
> Tableless as the skin it should change to.
>
> But it does work when I try to change to MySkin .. :(
>
> Does anyone have a recipe for doing this in 2.1, or have anyone done  
> something similar ?
>
> A nice feature for the future would be to choose the skin for a  folder
> from the "choose default view"  tab in the folder :)
>
>
> br,
> Sverre Helge Bolsted
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.
> Get Certified Today * Register for a JBoss Training Course
> Free Certification Exam for All Training Attendees Through End of 2005
> Visit http://www.jboss.com/services/certification for more information



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Mike Hyde () Re: Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink
If you only need to make changes to the style sheet on a per-folder basis, here is a method that I used.  the advantage of this approach is that all the different styles are still in one style-sheet, and there are no conditions in the registry.  This means that all the style-caching will still work, meaning there should be very little slowdown using this approach.

However, if your local styles involve more than just css changes (i.e. you have made changes to templates as well) then as far as I know, you are still going to have to use access rules.

Hope this helps
Mike

------------------------------------------------------------------------

In order to allow customised styles to be applied to any folder or sub folders, I ended up doing the following:

* Customise 'getSectionFromURL' (from plone_scripts)
* Edit the last line from:
    return "section-" + contentPath[0]
  to:
    return " ".join(["section-" + "-".join(contentPath[:d+1]) for d in range(len(contentPath))])

This expands the code that creates the "section-members" class attribute in the body tag.  It now adds a class for each folder in the path.

E.g. Imagine you have a folder structure that goes: /departments/marketing/news

The body tag now has the following class attributes:
  section-departments
  section-departments-marketing
  section-departments-marketing-news

So in ploneCustom.css, you can go:
.section-departments-marketing p { color: red }

to turn all paragraphs red in /departments/marketing and below

and then you could also go:
.section-departments-marketing-news p { color: green }

to override all the paragraphs to green in /departments/marketing/news


Sverre Helge Bolstad-2 () Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink
Thanks Mike an David !

I need to change the logo, graphics and some colors
so maybe I can use the section attribute solution
for now (if Im able to change the logo with it ?),
but it would nice to know how to do both and im a
newbie so I have questions for both of you. :)

I actually tried Mikes solution before posting here,
but didnt get it to work so..

should i customize getSectionFromURL on the filesystem,
or put it in the custom folder ?

my folder structure is
/kinesiske-kamp/om-kinesiske-kampkunster/new-folder

would then the attributes be
section-kinesiske-kamp
section-kinesiske-kamp-om-kinesiske-kampkunster
section-kinesiske-kamp-om-kinesiske-kampkunster-new-folder ?

and in ploneCustom.css:

.section-kinesiske-kampkunster-om-kinesiske-kampkunster-new-folder
p {
color: red }

?

and David :

how do I register a condition for a stylesheet, and what stylesheet is
registered with the portal ?

Thanks !

Sverre Helge




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
dconvent () Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink

> how do I register a condition for a stylesheet,
look at the config.py of DIYPloneStyle, it is quite explicit.
a condition is a TAL expression, it works the same way as for actions
(see portal_css and portal_actions)
and what stylesheet is
> registered with the portal ?
look at portal_css from the ZMI, it lists all the registered stylesheets

>
> Thanks !
>
> Sverre Helge
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the JBoss Inc.
> Get Certified Today * Register for a JBoss Training Course
> Free Certification Exam for All Training Attendees Through End of 2005
> Visit http://www.jboss.com/services/certification for more information



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
dconvent () Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink
In reply to this post by Mike Hyde
Mike Hyde wrote:
> If you only need to make changes to the style sheet on a per-folder
> basis, here is a method that I used.  the advantage of this approach is
> that all the different styles are still in one style-sheet, and there
> are no conditions in the registry.  This means that all the
> style-caching will still work, meaning there should be very little
> slowdown using this approach.
The ResourceRegistries is now cacheable, thanks to Florian Schultze.
So you can now play with conditions without affecting plone perfs.
Changes are in the svn trunk.
Personaly I prefer when I can avoid modifying plone templates and
scripts for further maintenance.

Your solution is interesting though.
Thx,
David

>
> However, if your local styles involve more than just css changes (i.e.
> you have made changes to templates as well) then as far as I know, you
> are still going to have to use access rules.
>
> Hope this helps
> Mike
>
> ------------------------------------------------------------------------
>
> In order to allow customised styles to be applied to any folder or sub
> folders, I ended up doing the following:
>
> * Customise 'getSectionFromURL' (from plone_scripts)
> * Edit the last line from:
>     return "section-" + contentPath[0]
>   to:
>     return " ".join(["section-" + "-".join(contentPath[:d+1]) for d in
> range(len(contentPath))])
>
> This expands the code that creates the "section-members" class attribute
> in the body tag.  It now adds a class for each folder in the path.
>
> E.g. Imagine you have a folder structure that goes:
> /departments/marketing/news
>
> The body tag now has the following class attributes:
>   section-departments
>   section-departments-marketing
>   section-departments-marketing-news
>
> So in ploneCustom.css, you can go:
> .section-departments-marketing p { color: red }
>
> to turn all paragraphs red in /departments/marketing and below
>
> and then you could also go:
> .section-departments-marketing-news p { color: green }
>
> to override all the paragraphs to green in /departments/marketing/news
>
>



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users
Mike Hyde () Re: Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink


On 10/27/05, David Convent <[hidden email]> wrote:
Mike Hyde wrote:
> If you only need to make changes to the style sheet on a per-folder
> basis, here is a method that I used.  the advantage of this approach is
> that all the different styles are still in one style-sheet, and there
> are no conditions in the registry.  This means that all the
> style-caching will still work, meaning there should be very little
> slowdown using this approach.
The ResourceRegistries is now cacheable, thanks to Florian Schultze.
So you can now play with conditions without affecting plone perfs.
Changes are in the svn trunk.
Personaly I prefer when I can avoid modifying plone templates and
scripts for further maintenance.

Oh cool - I wasn't aware of this.  I agree that modifying templates is not ideal, but as it was such a small mod I thought I would live with it.  The other slight disadvantage to using ResourceRegistry with conditions was that I was dealing with around 100 folders each potentially with their own styles.  It does sound a bit unwieldy to have 100 conditional entries in ResourceRegistries, all working on different levels and folders.  I say this purely from a manageability point of view - the actual site performance may well be just as good now that the caching is sorted out.
 
Mike

Mike Hyde () Re: Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink
In reply to this post by Sverre Helge Bolstad-2


On 10/26/05, Sverre Helge Bolstad <[hidden email]> wrote:
<...>
I actually tried Mikes solution before posting here,
but didnt get it to work so..

should i customize getSectionFromURL on the filesystem,
or put it in the custom folder ?

Initially I would customise via the ZMI just for testing purposes.  (I.e. find the script in the ZMI, press "customize" and use the copy in the custom folder)  Do not edit the original on the filesystem as your edits will then be overridden next time you upgrade plone.  Once it is working you can do a custom filesystem skin that includes this modification.
 

my folder structure is
/kinesiske-kamp/om-kinesiske-kampkunster/new-folder

would then the attributes be
section-kinesiske-kamp
section-kinesiske-kamp-om-kinesiske-kampkunster
section-kinesiske-kamp-om-kinesiske-kampkunster-new-folder ?

Guess so.  Lots of hyphens, but should still work.  Look at a page in new-folder and go view source in your browser and check what it has rendered.
 

and in ploneCustom.css:

.section-kinesiske-kampkunster-om-kinesiske-kampkunster-new-folder
p {
color: red }

looks like a typo to me.  I think you might mean:
.section-kinesiske-kamp-om-kinesiske-kampkunster-new-folder p { color: red }
 
Mike



Sverre Helge Bolstad-2 () Re: set custom skin for folder
Reply Threaded More More options
Print post
Permalink

> Initially I would customise via the ZMI just for testing
> purposes.  (I.e. find the script in the ZMI, press "customize" and
> use the copy in the custom folder)

I followed your recipe and it helped me do excactly what I wanted :)
thanks a lot !
Sverre Helge



-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Plone-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-users