John Poltorak wrote:
On Tue, May 31, 2005 at 06:23:11PM +0300, Vital Lobachevsky wrote:

John Poltorak wrote:

I want to provide a set of links on a Zope site dynamically. ie don't want to hard code a number of links, but would like to load them from an external source which I can add to independently, but I have no idea as to how to set about it.
Any ideas?

I'd be quite happy to have the links in a text file with one link per line.

1) Create a script that returns a list of links:

## Script (Python) "linkList"

return [

2) Use this script on your page. For example,

<tal:block repeat="link here/linkList">
  <span tal:replace="structure link" />

Many thanks for your suggestion.

Is there a worked example of doing this anywhere?

There seem to be quite a few steps involved in trying to get this working and I'm no expert in writing python scripts, and it will probably take me a couple of days to get this working.

Well, it's really easy. Create 'linkList' (Python Script) in the folder where you page lives or somewhere higher in folder hierarchy:

## Script (Python) "linkList"
return [
  ('', 'Google'),
  ('', 'Yahoo'),

If your page is Page Template, it maybe something like this

<h1>Search Engines</h1>
<tal:block repeat="item here/linkList">
  <a tal:content="python:item[1]"
     tal:attributes="href python:item[0]"></a><br />

If you page is DTML Method, you can do the same using <dtml-in> tag.

Zope maillist  -
**   No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to