Object relation Question?

Author Message

Nathan Kelly

Monday 05 September 2005 12:19:06 am

Hi there, me again...

I have been searching the forums for the answer to this question but so far I've had very little luck implementing this.

The website I am developing has a unique home page as opposed to the normal content pages, simply I have set up a pagelayout.tpl override and created a new template that lets me make my home page layout function correctly.

On the home page I have a couple of specific things I need to accomplish, this is what I need: -

1. I need to have a block wherein I can display a current promotion for a particular product or special event.

2. I need a block wherein I can display the most recent (or a selected) article from either the news section or sponsorship section (both sections use fairly straight forward article classes).

3. The remainder of the page is made up of a large static introduction image and some static links, these elements are basically hard coded into the template as they have no need to be dynamic. The home page may have a small amount of text within it but at this stage there is no text needed.

The promo block will need to be updateable, essentially I need to be able to add a new promotion whenever there is a need, also there will only ever be one promotion displayed at a time. However when a promotion is added I would like it to remain in the system so if it should need to be re-run it does not have to be re-created, in other words we don't want to delete promotions.

What I have looked at doing seems to be a simple way to do this but I'm not sure how to make it work.

I have created a new folder inside the media folder and called it Promotions, and then I created a new content class and named it promo. The promo class contains a title, an XMLfield and a related object for images (this may not be needed as I may control the image via CSS).

My home page is the root node (ID 2) and because my home page needs very little textural content there is no need to use the XMLfields to add content, therefore I don't want to embed the promo class within the XMLfield. What I would like to do is call the promo from the template. This would mean that when a new promo is run I can simply swap the old promo object relation with the new promo object relation.

I hope that makes sense so far?

The reason it becomes difficult to embed the promo object via the XMLfield of the folder class is simply due to the amount of static content within my home page template, the promo would in that case be called via the page_mainarea.tpl thus putting the promo block smack bang in the middle of any content there may be at a later date and in turn breaking my layout.

Calling the promo from the template using a specific object ID is also made difficult due to the idea of keeping past promo's in the system. What I need to do is call the object relation with some other method that does not rely on the object ID, but I'm not sure how?

I know that was long winded but I think its worth trying to make my goals clear that way I may get a clear answer ;). I'll leave it at that for now, I have a couple of other questions regarding the article block but they can wait for time being.

So if you are still with me and you have any suggestions for how to make this work I would greatly appreciate any input. There's a good chance I may be going about this the wrong way so if you feel that is the case please don't hesitate to correct me.

If you still have no idea what I'm on about I'll do my best to elaborate.

Thankyou for listening.

Pardon me while I burst into flames...

Xavier Dutoit

Monday 05 September 2005 2:24:51 am

Hi,

Makes sense to me, as I do it mostly like you.

I'd suggest to put the static content as the body of the node 2, as by experience static texts aren't that static, nor to mention a few added values, like being able to find it from the search engine.

As for the "how to retrieve the promo, I usualy fetch the children of the media/promotions node (fixed id) by reverse publication date, with a limit of 1. This obviously takes the latest one.

I don't understand the problem of the size of the static text, as it seems to be specific to you layout. I put these elements into a float or fixed position near the top, or within a side column and that does the trick.

X+

http://www.sydesy.com

Nathan Kelly

Monday 05 September 2005 5:04:32 pm

<i>I don't understand the problem of the size of the static text, as it seems to be specific to you layout. I put these elements into a float or fixed position near the top, or within a side column and that does the trick.</i>

I'll try to illustrate the layout as best I can, this may give you a better idea of how the page elements interact...

|----------Home page layout template-----------|
|                                              |
|----------Navigation--------------------------|
|                                              |
| |--------Static image-------| |---Promo----| |
| |                           | |            | |
Z Z                           Z Z            Z Z
| |---------------------------| |------------| |
|                                              |
| |-Static link| |-Static link| |-Latest News| |
Z Z            Z Z            Z Z            Z Z
| |------------| |------------| |------------| |
|                                              |
| |-----Possible Text (XMLblock output)------| |
| |                                          | |
Z Z                                          Z Z
| |------------------------------------------| |
|----------------------------------------------|

The problem I have is that any text inserted via the XMLblock should display at the bottom of the page, so if the promo is embedded in the XMLblock it will be difficult to make it appear at the top of the page. I know I can do this with CSS but I would prefer it if I don't have to resort to absolute positioning. So fetching the related object from the template would be the best way as far as I can tell.

As for the static content would you suggest that I insert this via the CMS?

One thing I find very frustrating about inputting elements via the XMLblock is the lack of support for block level elements like div tags. If I could input divs via the XMLblock I think this page would be extremely easy to layout.

I'm most likely making this all more confusing than it really is but I have very little experience with Ez, so finding the right way to do things the first time is a tad tricky.

Also is there any chance you could point me to a good example for retreving the promo? I have seen so many variations of the code that I'm not sure which is the best way to do it.

Cheers!

Pardon me while I burst into flames...

Gabriel Ambuehl

Tuesday 06 September 2005 1:17:40 am

You can wrap pretty much any valid XML in
<literal> </literal> tags in XMLBlock. You'll use the PDF export stuff (which is of limited use in my book) and such things, but it will display just fine.

Visit http://triligon.org

Roy Bøhmer

Tuesday 06 September 2005 1:31:38 pm

I'm afraid I don't get the problem 100%, but I'll try anyway.

As Xavier Dutoit suggests you should fetch the promos from the template. That means <i>indipendent</i> of the related objects in the node 2. http://ez.no/products/ez_publish_cms/documentation/reference/data_fetching/content/list explains how to do this.
Then you insert the fetched objects pretty much anywhere you want - comletely indipendent of any attribute from node 2.

You maybe find it convinient to override the full.tpl for node2 as well as pagelayout.tpl. At least I find it a bit more relaxing when I have to modify a template completly.

When I need to pick topstories for my frontages I usally avoid using the related content-feature. This is mainly because I can't controll the order of the objects. In stesad I add two attributes to the class: one ezObjectRelationList (ORL) and one ezObjectRelation (OR). In the ORL I manualle choose the first topstories. This is usally articles, but you can offcourse use your promp-class.
The object/node in OR holds the parent from which the x newst stories should be fetched from.

In the template I then use spesific views ( http://ez.no/products/ez_publish_cms/documentation/reference/template_functions/gui/content_view_gui ) to present the topstories. You don't need to do that, but if you do so you can set up several classes to have their own "promo-view". For me it has (almost) ruled out the need for an own promo-class.

I know this is not the intended use of ORL but...

Hope this can help, or at least give you some ideas.
- Roy

Nathan Kelly

Tuesday 06 September 2005 4:39:40 pm

Thanks for the suggestions, it's still a little fuzzy in my head but there are a couple of ideas here that I had not considered.

From all that has been said can I assume that I don't necessarily need to use related objects?

I figured that relating 1 particular promo to the home page at a time would be the most logical solution, but I'm still a little unsure of what other options (if any) are available.

Again thanks, I'll do some experimenting with the ideas expressed and see what I come up with.

Cheers!

Pardon me while I burst into flames...

Xavier Dutoit

Wednesday 07 September 2005 1:59:13 am

Hi,

Thanks Roy for sharing your trick.

I prefer to create a few extra nodes (in the media folder usualy), eg "top stories, promo home page, items in the left hand column...".

On the overrided templates (eg the home page one), I fetch the children of these nodes with some extra rules (eg, fetch only the latest children from the promo...).

If I need to order some of these items (eg the news), I use the order by priority rule for the children of the node 'top stories' and set the prio by hand et voila !

A last trick: when I'm in a good mood, I create a "dummy" class for these 'structural' nodes, and I override the full and line view to display nothing, so if a user type /media/promo he doesn't the list of all the promos.

X+

http://www.sydesy.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.