[Plone-Users] SkinChooser: Not working

0 views
Skip to first unread message

Jan Filip Tristan Hasecke

unread,
Dec 31, 2009, 10:18:59 AM12/31/09
to Plone...@lists.sourceforge.net
hi,

I want to have different folders to have different themes.
I am trying to make a Project( SkinChooser) with a view where you can choose a
theme and this theme shall be set to the folder.

I don't know if that is possible. I have ( I think so ) all the stuff I need,
but when I choose a theme, nothing happens, no error, no warning, just the ond
theme is displayed.

skinchooser.py file:

class SkinChooserView(BrowserView):
"""This is a View for changing the skin"""

template = ViewPageTemplateFile("templates/skinchooser.pt")

def __call__(self):
self.request.set("disable_border", True)

okbutton = self.request.get("button.submit")
if not okbutton:
return self.template()

text_input = self.request.get("skinname") # is "Hasecke Theme"
path_input = self.request.get("skinpath") # is "plone3_theme.hasecke
path_input = path_input.split(".") #("plone3_theme","hasecke")
print path_input
print text_input

tool = SkinsTool()
tool.addSkinSelection(text_input, path_input)

if text_input:
self.context.changeSkin(text_input) #here the theme shall be set to the
Folder.

print self.context.getCurrentSkinName()

return self.request.response.redirect(self.context.absolute_url())


In the end "print self.context.getCurrentSkinName()" returns the new Theme,
but the theme isn't displayed, the old theme is still displayed.

The page template, if needed:
[...]
<metal:main fill-slot="main">
<h1 class="documentFirstHeading" i18n:translate="header_choose_skin">
Choose another Skin
</h1>

<form method="get"
tal:attributes="action string:${context/absolute_url}/${view/__name__}">
<input type="text" size="20" name="skinname" value="Hasecke Theme" />
<input type="text" size="20" name="skinpath" value="plone3_theme.hasecke" />

<input type="submit" size="5" name="button.submit" value="Change"
class="context"/>

</form>


</metal:main>

[...]

I ran out of Ideas. I hope someone knows how to apply a new theme to one
Folder.
Thanks in advance

Filip Hasecke

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
Plone-Users mailing list
Plone...@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plone-users

Luciano Pacheco

unread,
Dec 31, 2009, 12:07:43 PM12/31/09
to Jan Filip Tristan Hasecke, Plone...@lists.sourceforge.net
Hi Jan,

On Thu, Dec 31, 2009 at 1:18 PM, Jan Filip Tristan Hasecke <filip....@googlemail.com> wrote:
hi,
[...]

I ran out of Ideas. I hope someone knows how to apply a new theme to one
Folder.
--
Luciano Pacheco
blog.lucmult.com.br

Jan Filip Tristan Hasecke

unread,
Dec 31, 2009, 1:01:12 PM12/31/09
to Plone...@lists.sourceforge.net
>
> I did this using access rule, you can see this here:
> http://dev.plone.org/collective/browser/sc.base.hotsites/trunk/sc/base/hots
>ites/subscribers.py#L49
>
> [],

Hi, I've copied the necessary part form the code. Now I have this:


class SkinChooserView(BrowserView):
"""This is a View for changing the skin"""

template = ViewPageTemplateFile("templates/skinchooser.pt")

def __call__(self):
self.request.set("disable_border", True)

okbutton = self.request.get("button.submit")
if not okbutton:
return self.template()

text_input = self.request.get("skinname")

script_body = '''
context.changeSkin('%s', context.REQUEST)
return 1
''' % text_input

if not 'setSkin' in self.context.objectIds():

self.context.manage_addProduct['PythonScripts'].manage_addPythonScript('setSkin')
self.context['setSkin'].write(script_body)

self.context.manage_addProduct['SiteAccess'].manage_addAccessRule('setSkin')

return self.request.response.redirect(self.context.absolute_url())

Ok now the skin changes, BUT the result is not the new skin, but a mixture of
the old and new skin. I think I need to reset all old Themesettings before
setting the new one. But I don't know how to do that :(

Luciano Pacheco

unread,
Dec 31, 2009, 1:38:48 PM12/31/09
to Jan Filip Tristan Hasecke, Plone...@lists.sourceforge.net
On Thu, Dec 31, 2009 at 4:01 PM, Jan Filip Tristan Hasecke <filip....@googlemail.com> wrote:
>
> I did this using access rule, you can see this here:
> http://dev.plone.org/collective/browser/sc.base.hotsites/trunk/sc/base/hots
>ites/subscribers.py#L49
 
class SkinChooserView(BrowserView):

       """This is a View for changing the skin"""
       template = ViewPageTemplateFile("templates/skinchooser.pt")

       def __call__(self):
               self.request.set("disable_border", True)
               okbutton = self.request.get("button.submit")
               if not okbutton:
                       return self.template()

               text_input = self.request.get("skinname")
               script_body = '''
context.changeSkin('%s', context.REQUEST)
return 1
               ''' % text_input

               if not 'setSkin' in self.context.objectIds():
self.context.manage_addProduct['PythonScripts'].manage_addPythonScript('setSkin')
               self.context['setSkin'].write(script_body)
self.context.manage_addProduct['SiteAccess'].manage_addAccessRule('setSkin')
               return self.request.response.redirect(self.context.absolute_url())



Ok now the skin changes, BUT the result is not the new skin, but a mixture of
the old and new skin. I think I need to reset all old Themesettings before
setting the new one. But I don't know how to do that :(

Now, the problem is your skin definitions.

Can be viewlets and browser views registered to all skins.

Your new skin can be based on the old default skin.

What skins you are using in your tests ? 

Jan Filip Tristan Hasecke

unread,
Jan 1, 2010, 7:54:34 AM1/1/10
to Plone...@lists.sourceforge.net

>
> Now, the problem is your skin definitions.
>
> Can be viewlets and browser views registered to all skins.
>
> Your new skin can be based on the old default skin.
>
> What skins you are using in your tests ?
>
> [],

I use Themes based on the default Plone theme

You can download one ofthe themes here:
http://filip.hasecke.com/stuff/plone3_theme.midnight/view

The problem is viewlets which are displayed in one theme are displayed in
another, the viewlet hides are not updated. And there is a problem with the
CSS cache. Also the whole skins folder is not replaced by the new themes skin
folder :/

Luciano Pacheco

unread,
Jan 1, 2010, 10:00:36 AM1/1/10
to Jan Filip Tristan Hasecke, Plone...@lists.sourceforge.net
On Fri, Jan 1, 2010 at 10:54 AM, Jan Filip Tristan Hasecke <filip....@googlemail.com> wrote:

>
> Now, the problem is your skin definitions.
> Can be viewlets and browser views registered to all skins.
> Your new skin can be based on the old default skin.
> What skins you are using in your tests ?

I use Themes based on the default Plone theme

You can download one ofthe themes here:
http://filip.hasecke.com/stuff/plone3_theme.midnight/view

The problem is viewlets which are displayed in one theme are displayed in
another, the viewlet hides are not updated. And there is a problem with the
CSS cache. Also the whole skins folder is not replaced by the new themes skin
folder :/

So... you have reinstalled your theme product ?

This behavior (viewlets.xml not working and themes skin folder not replaced) seems to be the product isn`t installed correctly.

You could get a look in portal_skins in the tab "Properties" and see the skin names and skin layers that will be used.

Jan Filip Tristan Hasecke

unread,
Jan 1, 2010, 10:09:58 AM1/1/10
to Plone...@lists.sourceforge.net
> So... you have reinstalled your theme product ?
>
> This behavior (viewlets.xml not working and themes skin folder not
> replaced) seems to be the product isn`t installed correctly.
>
> You could get a look in portal_skins in the tab "*Properties*" and see the

> skin names and skin layers that will be used.
Yes also with reinstalling there are some complications with the
main_template, but when I reinstall the theme for the whole site the CSS and
the viewlets are correct.

Is it possible to reset all settings to plone default, for just one folder,
before changing the skin?

I need to have all settings like in the default plone theme and I need an
empty style, else all settings of the old theme will be kept, if the new skin
does not change it explicitly.
Is it possible to reset all settings, but just for one folder. Hmm, I don't
think so :/
Does anyone know something about that?

Luciano Pacheco

unread,
Jan 1, 2010, 10:27:44 AM1/1/10
to Jan Filip Tristan Hasecke, Plone...@lists.sourceforge.net
On Fri, Jan 1, 2010 at 1:09 PM, Jan Filip Tristan Hasecke <filip....@googlemail.com> wrote:
> So... you have reinstalled your theme product ?
>
> This behavior (viewlets.xml not working and themes skin folder not
> replaced) seems to be the product isn`t installed correctly.
>
> You could get a look in portal_skins in the tab "*Properties*" and see the
> skin names and skin layers that will be used.
Yes also with reinstalling there are some complications with the
main_template, but when I reinstall the theme for the whole site the CSS and
the viewlets are correct.

Is it possible to reset all settings to plone default, for just one folder,
before changing the skin?

I need to have all settings like in the default plone theme and I need an
empty style, else all settings of the old theme will be kept, if the new skin
does not change it explicitly.
Is it possible to reset all settings, but just for one folder. Hmm, I don't
think so :/
Does anyone know something about that?

Now... becoming hard to help you... once I don't a theme guy. :-)

But the main_template issue can be solved with skin layer.

In Properties tab, on portal_skins, you can choose for each theme the layers.

For theme 1 you put the main_template in the layer "x" (or left the default of Plone)

For theme 2 you remove the layer "x" and put the other main_template in other layer.

You can achieve this, only change the order of layers.

If CSS is on skin, you can do the reorder of skins too.

So, you will understand why we use the custom folder. We use the custom folder to customize things, because it is on top of the skin layers, if you put the custom folder in bottom of the layers list, you break the custom functionality. :-)

For each skin you can have its custom folder (eg: custom_1 and custom_2).

[],
--
Luciano Pacheco
blog.lucmult.com.br
Reply all
Reply to author
Forward
0 new messages