Personal tools
You are here: Home Lists ZPUG DC List Archives 2004 2004-08 Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / David Diskin <david.diskin@verizon.net>
Navigation
Log in


Forgot your password?
New user?
Mailing Lists
You can read our ZPUGDC mailing list archives online.
You can subscribe to our mailing list:
Book Review

The Definitive Guide to Plone

Reviewer: joel
 

Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / David Diskin <david.diskin@verizon.net>

Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
David Diskin <david.diskin(at)verizon.net>
2004-08-13 09:01:16 [ FULL ]
I'm struggling with this Plone problem.   (Some)Users want a different 
icon for
subfolders - e.g. a folder icon of a different color than yellow.   I 
created a new blue folder icon
which I put in portal_skins/custom.  Then, I'm trying to modify the 
portlet_navigation template (not a
trivial exercise), using the fact that te['indent'] is an integer I 
believe, as it's used that way in
the code.  I've attached the portlet_navigation.pt I'm using - from Plone 
2.0 branch of subversion.

Here are the original lines and my modification.

Original (line 54):

<img height="16" width="16" alt=""
          class="navIconRoot"
          tal:attributes="src string:${here/portal_url}/site_icon.gif;
           title sibling/Type;" />

My modification:

<img height="16" width="16" alt=""
         class="navIcon"
          tal:attributes="src python:test(te['indent'] > 0, 
string:${here/portal_url}/${portal_skins/
custom/altfolder.gif}, string:${here/portal_url}/${sibling/getIcon});
           title sibling/Type;" />

First, I can't get this to even compile as I'm getting this error:

Compilation failed
TAL.TALDefs.TALError: Python expression error:
invalid syntax (getIcon})", line 1) in expression 
"python:test(te['indent'] > 0, string:${here/
portal_url}/${portal_skins/custom/altfolder.gif}, 
string:${here/portal_url}/${sibling/getIcon})", at
line 57, column 29

So, first I need to get this to at least compile.  Second, I'm not sure 
this is even correct or the
best way to do this.  Any suggestions are most welcome.  Thanks,

David
[...]
Attachments: 
Original_portlet_navigation.htm text/html - 5794 Bytes

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / Joel Burton <joel@joelburton.com>

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
Joel Burton <joel(at)joelburton.com>
2004-08-14 13:23:10 [ FULL ]
David Diskin wrote:[...]

David --

Do you want _all_ subfolders to be colored blue? Or just certain ones. 
If it's certain ones, a better way would be have a different portal 
types for these different-color ones.

Or, if there's no difference in the folders, your way is reasonable.

You're misunderstanding the use of 'string:', though--it can't be used 
here, only at the start of the expression. You could use the string() 
function in TAL, though, so you could say:

python: test(..., string('${here/portal_url}...'), string('...'))

but that seems uneccessary.

Better to just do it all in Python:

python: test( te['indent'],
               '%s/altfolder.gif' % portal_url,
               '%s/%s' % portal_url, sibling.getIcon()
              )

(untested, let me know if it doesn't work & you can't figure it out.)

Also, note that we want to return the string URL here. Your try (besides 
having the 'string' wrong also try to return the actual *value* of 
altfolder.gif, which is *not* what you want; you want to return the URL.

HTH,

- j.

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / David Diskin <david.diskin@verizon.net>

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
David Diskin <david.diskin(at)verizon.net>
2004-08-14 16:05:26 [ FULL ]
Joel,

Thanks very much for the help.  I now understand my problem with using 
'string'.   However, I can't decipher your code:
  python: test( te['indent'],
                 '%s/altfolder.gif' % portal_url,
                 '%s/%s' % portal_url, sibling.getIcon()
                )

What is (percent sign)%s?  Did  my email mess this up?

David



On Sat, 14 Aug 2004 14:30:20 -0400, Joel Burton <joel(at)joelburton.com> 
wrote:
[...][...][...]

[...]

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / Joel Burton <joel@joelburton.com>

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
Joel Burton <joel(at)joelburton.com>
2004-08-14 16:12:34 [ FULL ]
David Diskin wrote:[...]

It's use of Python's formatting strings, similar to printf (if you're 
familiar with that from C).

#!/usr/bin/python

foo="David"
bar=7

print "Hi %s, your number is %s" % (foo, bar)
  -> "Hi David, your number is 7"

Read all about 'em in the Python language tutorial or in _Dive_into_Python_.

- j.

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / David Diskin <david.diskin@verizon.net>

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
David Diskin <david.diskin(at)verizon.net>
2004-08-14 16:44:05 [ FULL ]
Joel,

Got it and it works fine.  THANKS.   Perhaps, you could answer one more 
question about this that has me puzzled.  How does Plone find the 
altfolder.gif file?   I'm saying to look for it at 
portal_url/altfolder.gif, whereas it's in the 
portal_url/portal_skins/custom folder.   Is it because if  Plone can't 
find something it automatically looks in the custom folder?

Thanks again.  So far, I've found the Plone/Zope/Python community to be 
very helpful and supportive of newbies.

David

On Sat, 14 Aug 2004 17:19:34 -0400, Joel Burton <joel(at)joelburton.com> 
wrote:
[...][...][...]

[...]

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet / Joel Burton <joel@joelburton.com>

Re: [ZPUGDC] Plone Help Needed : Providing a new (sub)folder icon in navigation portlet
Joel Burton <joel(at)joelburton.com>
2004-08-14 16:55:29 [ FULL ]
David Diskin wrote:[...]

David --

Take a few minutes and read the parts of the Plone Book on the 
portal_skins tool; essentially, things in portal_skins are looked up as 
the "skins" for Plone stuff. It's a pretty critical and central part of 
  Plone.

- j.

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: