Forums / Setup & design / How to only display the three most recent articles published?

How to only display the three most recent articles published?

Author Message

Sergio Herrera

Friday 04 February 2005 1:14:10 pm

on /Music/Hip-Hop I want to display the 3 most recent artciles published under the Hip-Hop folder in a catching eye design. Then further down on the page I want to display the other 3-4 articles prior to the newst 3 in a different design. I don't know how to do it, I've read a couple of section on the documentation here.

I would also like this 3 newest articles not only come from the Hip-Hop folder but from different folders under the Hip-Hop folder for example from hip-hop/artists/jlo/news/here_the_news_articles.

I'm also having trouble in the full_folder view or line_folder view, if I unhide the folders under the hip-hop directory, then they show up right after the first featured article, I can't find a way to have this folders visible but at the same time not to be displayed there.

Here's an image of what I'm talking about:

http://micantina.com/temp_05.gif

The 3 red boxes are the 3 newest articles, the box in pink is where I want the older articles to be displayed.

Is this even possible in Ez Publish?

Eivind Marienborg

Friday 04 February 2005 2:07:29 pm

check out the docs, here: http://www.ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch

The functions that are most relevant to you, are "limit" (limits the number of articles to a number you specify, e.g. 3), and "offset" (defines how many articles to skip before starting to display).

So, if you use this together with the sort_by (controlling what way the articles are sorted, e.g. the last published first, the first published first, by name, etc), you can do what you're trying to.

Sergio Herrera

Tuesday 15 February 2005 3:20:19 pm

Thanks, but I'm fresh new to Ez Publish. This is harder than writing PHP. I would love to see more examples of real actual working solutions and how to edit them. Or/and explanations of what all the code means like

{section show=is_unset( $versionview_mode )} 
	    {section show=$node.object.data_map.show_children.content} 
		  {let page_limit=3 list_items=array() list_count=6} 
		    {section show=or( $view_parameters.day, $view_parameters.month, $view_parameters.year )} 
			  {let time_filter=array( and, array( 'published', '>=', maketime( 0, 0, 0, $view_parameters.month, cond( 

$view_parameters.day, $view_parameters.day, 1 ), $view_parameters.year ) 
), array( 'published', '<=', maketime( 23, 59, 59, cond( 

$view_parameters.day, $view_parameters.month, $view_parameters.month|inc ), cond( $view_parameters.day, $view_parameters.day, 0 ), $view_parameters.year ) ) )}         
			    {set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, offset, $view_parameters.offset,
attribute_filter, $time_filter, sort_by, $node.sort_array, limit, 
$page_limit ) ) list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )} 
			  {/let} 
			{section-else} 
			  {set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, offset, $view_parameters.offset, sort_by, 
$node.sort_array, limit, $page_limit ) )} 
			  {set list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )} {/section}

What does all that mean? u know like giving an explanation of what page_limit stands for in this section, parent_node_id etc. So that we could later modify all this code and write more, I don't know what a class is in Ez Publish, I know that in HTML it's used like

<a class="green_link">

but I have no idea what a class or parameter or node is in Ez Publish, maybe a more/better organized documentation would help, or a more simple to use admin interface. I just need help setting my site up the design and how it will work, from there on I can take it on my own. I've been creating sites since 2001, learned Macromedia Dreamweaver, Flash, Fireworks in a couple of weeks but I can't learn a bit about Ez Publish I just don't know what to do, I want to do so many things that would be all dynamic but I can't.

From the code above I can only show the latest three articles but only inside that folder but I would also like to include articles published in other folders within that folder to show up, additionally I would also like to display the next 3 newest articles in a different format in the same page, then display the lates photo galleries, lates videos, lates MP3s,etc on that same page but I can't figure out how on earth to do that.

Thanks.

Eivind Marienborg

Tuesday 15 February 2005 8:04:43 pm

I had the same troubles when I first started using eZ - It seemed big and hard to both use and understand. My best advice is to read the documentation thorougly, and just try and fail with your own templates. And spaming the forum with stupid questions, of course ;)

But regarding your question, I think I'd advice you to read at least the following parts of the docs:

About content(classes etc): http://www.ez.no/ez_publish/documentation/toc/(from)/35680 (Be patient - The actual class-info a couple of pages out. Use the next-links at the bottom)

About getting objects from multiple folders, you might get a hint by following this tutorial:
http://www.ez.no/ez_publish/documentation/toc/(from)/36647

Sorry to mention this if you've already read these.

Regarding the page_limit etc:

{let page_limit=3 page_count=6}

A let-tag lets you define variables. So if you study your code, you will see that the variables defines inside let-tags are used again later.

The key to getting articles and mp3's from several directories, is the fetch:

{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, offset, $view_parameters.offset,
attribute_filter, $time_filter, sort_by, $node.sort_array, limit, 
$page_limit ) ) list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )} 

As you can see, this let defines list_items, consisting of the actual items, and list_count, which counts the number of objects returned.

To fetch stuff from other folders inside the folder, use the depth variable:

depth, 2

This will get you objects two levels down from where you currently are. The depth parameter is used in the fetch, like this:

{set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id, offset, $view_parameters.offset, attribute_filter, $time_filter, sort_by, $node.sort_array, depth, 2, limit, $page_limit ) ) 
list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id, depth, 2 ) )} 

Sorry if this doesn't help much.. Halfway through this post I started realizing that I really shouldn't write forum replys at 5am.. ;)

Ɓukasz Serwatka

Tuesday 15 February 2005 11:21:50 pm

{let page_limit=3
     col_count=3
     children=fetch('content','list',hash(parent_node_id,HIP-HOP-NODE,limit,$page_limit, sort_by, ('published', true() ) ))}

<table width="100%" cellspacing="0" cellpadding="4">
<tr>
{section name=Child loop=$children}
    <td>
    <p><a href={$Child:item.url_alias|ezurl}>{$Child:item.name}</a></p>
{attribute_view_gui attribute=$Child:item.object.data_map.body}
    </td>
    {delimiter modulo=$col_count}
</tr>
<tr>
    {/delimiter}
{/section}
</tr>
</table>
{/let}

replace HIP-HOP-NODE with your hip hop folder node

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog