I have to make some changes to the knowledge bank today. Whenever service providers key in their homepage, sometimes they do not include the http:// part of the address and the default plone behaviour is to consider it an internal link and thus it will link back into the knowledge bank. My first idea was to change the way the products save it's data (ie: appending the http if it is missing). But after some googling I find that would not be very wise. It's better to make the product template append the http if it was missing.
So after much googling I found a few references:
http://www.owlfish.com/software/simpleTAL/tal-guide.html
http://wiki.zope.org/ZPT/TALSpecification14
http://svn.python.org/projects/tracker/instances/python-dev/html/keyword.item.html
http://mail.zope.org/pipermail/zpt/2003-August/004774.html
So after much testing it out, this is what works:
It's working great. And just for completion sake I also changed so that the bracket around the name will not be shown if there is no phone number (ie: length of phone number is 0)
great stuf.. :D
So after much googling I found a few references:
http://www.owlfish.com/software/simpleTAL/tal-guide.html
http://wiki.zope.org/ZPT/TALSpecification14
http://svn.python.org/projects/tracker/instances/python-dev/html/keyword.item.html
http://mail.zope.org/pipermail/zpt/2003-August/004774.html
So after much testing it out, this is what works:
<tal:x tal:define="gothttp python: (path('here/homepage')[:7]=='http://')">
<tal:x tal:condition="gothttp">
<a tal:attributes="href here/homepage"><span tal:replace="here/Title"/>'s Homepage</a>
</tal:x>
<tal:x tal:condition="not:gothttp">
<a tal:define="homepage python: 'http://'+path('here/homepage')" tal:attributes="href homepage"><span tal:replace="here/Title"/>'s Homepage</a>
</tal:x>
</tal:x>
It's working great. And just for completion sake I also changed so that the bracket around the name will not be shown if there is no phone number (ie: length of phone number is 0)
<span tal:define="phonelen python:len(path('here/contactPhone'))" tal:condition="phonelen">
<span tal:replace="here/contactPhone"/> ( </span><span tal:replace="here/contactName"/><span tal:define="phonelen python:len(path('here/contactPhone'))" tal:condition="phonelen">)</span>
great stuf.. :D

0 comments:
Post a Comment