Certain Stories in Certain Places

Author Message

Matt Reston

Thursday 06 October 2005 8:40:48 am

Hey,
If you quickly glance over a news site such as BBC News, Sky News, etc then they have the main articles usually 3 or 4 set out in one place, and even more articles (NOT including the ones already mentioned) to the right/bottom .. wherever they may be.

Is this possible with ezPublish? And is it possible to create this on the frontpage and sub-section news areas, including the images for the 3 or 4 main stories that are actually linked to the articles themselves?

Matt Reston

Friday 07 October 2005 8:07:47 am

Also just to make my explanation a little clearer, and to urge for a little more help:

 ___________________________
|                   | OTHER |
| MAIN STORY(1)     |STORIES|
|    + PIC          | (4-9) |
|___________________|       |
|MAIN     | MAIN    |       |
|STORY(2) | STORY(3)|       |
|___________________|_______|

I'd hope to do this for each section of news - World, UK, College, Science/Tech etc.

The numbers next to the areas are the article number. For example the number 1 is the latest article and 2 is the second to last article, and number 3 is the third to last article - and so on and so forth.

All i want to know is if it is possible to recall a certain article in relation to when it has been written. Also if anyone could, some examples of how it could be used, as i'm rather new to all this.

Thanks in advance.

Arran Price

Sunday 09 October 2005 5:25:41 pm

Hi Matt,
this is definetly possible.
You are going to need to create a customised template to do this (just doing the tutorial and it will all become clear). All you are really going to do is fetch (look up fetch examples in the documentation) articles from different sections. You can do your fetches based on priority/published date etc and only bring in the number that you require.
This is a fairly common thing to do.

here is a code snippet that may help

{set news=fetch( content, list, hash( parent_node_id, $news_node, 
                                      sort_by, array( priority, false() ),
                                      offset, $offset,
                                      limit, $limit )
                                     ) 
}

{*show the main news item*}
{section loop=$news}
   <div id="homepage-sidenews">
   	<h2>{attribute_view_gui attribute=$item.object.data_map.title}</h2>
   	
   	{section show=is_set($item.object.data_map.image)}
   	   {attribute_view_gui css_class=content-image-side attribute=$item.data_map.image.content.data_map.image image_class=gallerythumbnail}
   	{/section}
   	
   	<p>{attribute_view_gui attribute=$item.object.data_map.intro}</p>
   	
      <div class="more-icon"><a href={$item.url_alias|ezurl}><img src={"/images/icon_more.gif"|ezdesign} border="0"></a></div>
      
   </div>	
{/section}  

the above example fetches based on priority.

strongly recommend reading through the tutorial and fetch documentation.

Arran

Matt Reston

Monday 10 October 2005 10:22:06 am

Cheers very much for that Arran.

I'm still quizzed as to how to do article 1 in one place and then 2 and 3 below then 4-9 etc somewhere else.

All this template coding is very new to me, and i've read the related documentation. But i never remember seeing any relation to the article number being defined in certain places where i'd like them.

Apologies for having so many questions.

Arran Price

Monday 10 October 2005 5:56:45 pm

Hi Matt,
Basically if you do a fetch, you will end up with an array of objects (in your case of articles). You can then specify which article in the array to display (and where) with in the template you can create. In my example, I loop through the articles as Im displaying them in the same way, just one after another, you can put them in some sort of table or whatever you want.

breaking down the code a little

{set news=fetch( content, list, hash( parent_node_id, $news_node, 
                                      sort_by, array( priority, false() ),
                                      offset, $offset,
                                      limit, $limit )
                                     ) 
}

this just fetches the articles I want, if I want the 2nd 3rd and 4th articles (note I use priority), I could set the offset to 1 and the limit to 3. If I ant the 1st and 2nd articles offset=0 limit=2.

the loop part of the code, is grabbing each item in the array, and applying a stylesheet to and displaying the attributes ie title, intro etc.

the chess club tutorial on this website should go through things like this.

cheers

Arran

Matt Reston

Tuesday 11 October 2005 10:54:57 am

Thanks again, for such an excellent response - it really does make sense now.

Once again i'm thinking what a truly great script this is! Well done to the ez team. =)

Yngve Bergheim

Wednesday 12 October 2005 1:13:24 am

Have a look at this tread: http://ez.no/community/forum/setup_design/dynamic_right_column

It discusses a similar problem, and I have just made some templates and classes with this approach that is doing exactly what you are looking for.

Why is dynamic sidebar not default in eZ?

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