Setting and retrieving a list of linked objects
Hi people, My problem is this: I have a ZClass "article". I´m trying to make each article instance show a menu list of "related articles" that will display the title of each target instance as the link to it. i.e.: <p>Related articles</p> <a href="www.mysite.com/path_to/article1">Article One's Title</a><br> <a href="www.mysite.com/other/path_to/another/article1">Another Article One's Title</a><br> <a href="www.mysite.com/other/path_to/article2">Article Two's Title</a><br> Problems: - I don't want the link being the target article's path stored in a variable as it will be easily broken (and I will have to learn how to retrieve an object's property out of its path, anyway). - I can't simply store the id of the object as this object may not be found in the acquisition path and it might be duplicated, so I will need to store its context too. Any idea? PS.: OK, let's make an unique id for each instance, if this helps.
Pablo Ziliani writes:
My problem is this: I have a ZClass "article". I´m trying to make each article instance show a menu list of "related articles" that will display the title of each target instance as the link to it. i.e.: <p>Related articles</p> <a href="www.mysite.com/path_to/article1">Article One's Title</a><br> <a href="www.mysite.com/other/path_to/another/article1">Another Article One's Title</a><br> <a href="www.mysite.com/other/path_to/article2">Article Two's Title</a><br>
Problems: - I don't want the link being the target article's path stored in a variable as it will be easily broken (and I will have to learn how to retrieve an object's property out of its path, anyway). - I can't simply store the id of the object as this object may not be found in the acquisition path and it might be duplicated, so I will need to store its context too. How you determine for a given article, which other articles are related?
Try to implement your criterion as a search and use ZCatalog to execute the query. ZCatalog allows you to obtain the path to any result item, to be readily used in your link. More info on ZCatalog in the Zope book and <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> Dieter
participants (2)
-
Dieter Maurer -
Pablo Ziliani