Forums / Developer / relating objects

relating objects

Author Message

Rinze Cats

Wednesday 14 April 2004 9:04:51 am

Hiya,

I am creating an online magazine. Every edition has a variety of articles. I want to achieve that all the articles in the 'january edition' or the 'february edition' are related to eachother. In the ideal situation I would create all the articles, without publishing them, and publish them all at once when I publish the new homepage for this edition. (so publishing the homepage would result in publishing all articles in this edition).

From what I read in the documentation, the 'keyword' datatype could be used. So i added a keyword field to my article class, and my homepage class, but 'things aren't relating'. I also experimented with the 'object relation' datatype, but it doesn't seem to work.

I use this code which I got from the documentation on this site.:

{let related=$node.object.data_map.keywords.content.related_objects}
{section show=$related}
<h2>Related documents</h2>
<ol>
{section name=Related loop=$related}
<li><a href={$:item.url_alias|ezurl}>{$:item.name}</a></li>
{/section}
</ol>
{/section}
{/let}

I think I am going about it the wrong way, but can't figure this one out at all!

Many thanx for any help / pointers you can give me!

John Dalton

Thursday 15 April 2004 1:21:10 pm

I'm still working on my first EZPublish site, but it seems to me that what you're trying to do would be much easier if you put all of the articles for a given issue into the same folder. That is, create a new folder for each issue which has all the content for that issue.

Then it's easy to find all the articles for a given issue by simply listing everything in that folder. Your archive listing just has to know where all the folders are, and you don't have to worry about object relations at all.

I think if you try to do this with an object relation list for each article which points to all other articles in the same issue, it will get very messy and difficult to maintain.

Rinze Cats

Monday 19 April 2004 1:43:46 am

That does seem to be the way to go, the only problem is that all articles are placed in a certain category, and each category has it's own layout. I use a folder for each category and assign a section to the folders. Per section I can define the styles and Images. I am currently using related objects to combine all articles, since it seems that 'keywords' only works for objects of the same class

John Dalton

Monday 19 April 2004 4:35:02 pm

Ok, perhaps another approach would be to add an "issue" attribute to your article class. Put the issue number (or date, or whatever) in this field for each article, and then use fetch with an attribute filter to grab all of the articles with that attribute set to a certain value.

Have a look here:
http://ez.no/ez_publish/documentation/reference/data_fetching/content/list
I think example 10 would do the job if you checked for something like "article/issue = 200404" instead.

The related objects appraoch probably isn't too bad though if they're just all related to the homepage for that issue.

Rinze Cats

Wednesday 21 April 2004 12:59:35 am

Hi and thanx for the response!

I have a working 'related objects' solution at the moment. However, will it be possible somehow to publish the homepage, causing all articles in the issue to be published as well? Or would the use of a common attribute facilitate this better? Or can't this be achieved at all?

Concerning related objects. Can this also be a two way function? In other words, can I relate the article to the homepage causing it to be added in the homepage's related objects list?

Sebastiaan van der Vliet

Wednesday 21 April 2004 4:55:22 am

Hi,

We are working on an online magazine as well. The way we set it up is as follows: we created a class "issue" with a number of properties, including the checkbox option "current issue". We then created a folder called "back issues" in which you can add issue objects. All classes in the magazine (event, link, document, article') share the same attribute "include in issue". We changed the admin template slightly, so that the back issue objects are shown in a dropdown list. This is a bit more userfriendly than the "browse for related" objects function.

Once all items are tagged in this way, the homepage starts with the following statements:
first: select a single issue object marked as current,
second: select all objects (articles, links, events, etc) which have that issue as a related object.

Using the issue class it is also possible to define specific articles as featured items.

Its probably not the most effecient approach, but we've got the site cached. The latest issue is launched by simply changing the "current issue" attribute.

Regards,
Sebastiaan

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

Rinze Cats

Thursday 06 May 2004 1:08:22 am

Hi, I have implemented a 'current issue' system as well, but run in to a problem.
I have current issues and archived issues.

all issues use the same pagelayout.tpl. in this template I select the homepage with current issue check and display it. Works fine. However, when opening a homepage from the archive, the template will check the current issue attribute, and open the current issue.

I have solved this by copying my pagelayout. one including the check. This is only used on first visit. This is a very ugly sollution since it involves copying my entire page template. I think I want to create a start template the finds the current issue and redirects to it, but I don't know how to implement this!

Another thing:
I relate articles to my homepage to assign them to a certain issue. Relating is a nasty job cause all articles reside in different folders. Is there a way to change the admin template to list all articles of an issue in one view,allowing the editor to relate them all at once. I have already included an issue attribute in my articles to distinguishe them!

many thanx!

Mark Marsiglio

Tuesday 18 May 2004 10:52:04 am

Rinze...Unfortunately I cannot help with the code to do it, but it is my understanding that the admin interface can be customized with override templates just as the user interface. It should be possible to create a custom view in the admin interface to create the listing that you desire.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Jack Rackham

Tuesday 17 August 2004 12:02:16 pm

Sorry wrong forum!