Displaying picked articles in the home frontpage [SOLVED]

Author Message

Lo' F.

Wednesday 25 August 2010 11:30:47 am

Hi there!

Struggling again!

I have a main folder that contains number of sub-folders each of them containing sub-folders which contain articles.

In the home page (embedded in the center column of the frontpage class) I need to display the preview (just the article's date and the short description) of some articles picked from different folders (e.g. folder1/subfolder5/subfolder7/article2 - folder3/subfolder5/subfolder4/article8 - and so on) which my client has to decide at his own discretion on a daily basis and a straightfoward action (really handy!).

...

My poor and definitely wrong attempt was:
- from the administration side, I created an extra folder object.
- Picked some articles from different location and add a collocation to this new created folder.
- In the center column of the home page frontpage embedded the "highligh articles" folder "Vertically listed sub items".
- tried to override the view of the line/article.tpl by creating a new override file line/article_preview.tpl strictly related to this page only which anyway I couldn't make it work!

Please help!!!!!!!!!!!!!!

loredanaebook.it

Robin Muilwijk

Wednesday 25 August 2010 12:45:05 pm

Hi Lo' F,

Can you let us know if the site in question is based on eZ Publish or eZ Flow? With eZ Flow this would be easy to accomplish by using a manual block where you client would be able to pick the articles he'd like to show. I'm guessing the site is based on eZ Publish?

Regards Robin

Board member, eZ Publish Community Project Board - Member of the share.ez.no team - Key values: Openness and Innovation.

LinkedIn: http://nl.linkedin.com/in/robinmuilwijk // Twitter: http://twitter.com/i_robin // Skype: robin.muilwijk

Lo' F.

Wednesday 25 August 2010 1:05:56 pm

"

Hi Lo' F,

Can you let us know if the site in question is based on eZ Publish or eZ Flow? With eZ Flow this would be easy to accomplish by using a manual block where you client would be able to pick the articles he'd like to show. I'm guessing the site is based on eZ Publish?

Regards Robin

"

Right guess.. it's based on eZ publish.

Tell me I can make it somehow..!

loredanaebook.it

Gabriel Finkelstein

Wednesday 25 August 2010 5:05:40 pm

What I usually do is add locations for the selected articles under an object of class "Homepage". Then in the full view of the "Homepage" class, I show each of it's children with a "home" view.

Lo' F.

Friday 27 August 2010 5:39:19 am

Gabriel, Thank you for your reply.

What you say is not wrong (I thought the same way too as a possible solution) but the thing is that the Home page is the root. When I create an object of the class under it, it is added as a top menu link.
Although I can prevent it from being displayed with a customized if condition, I have been thinking of another way:

In the frontpage.tpl file, inside /extension/ezwebin/design/ezwebin/override/templates/full/ (I use ezwebin extension), on the top of center-column, included an external file..

<div class="center-column-position">
            <div class="float-break center-column">
                <div class="overflow-fix">
                <!-- Content: START -->
{if $node.node_id|eq(2)}
  {include uri='design:content/primo_piano.tpl'}
{/if}
...

..which a created inside /extension/ezwebin/design/ezwebin/templates.content/...

<h2 class="primopiano">Primo Piano</h2>
{def $news=fetch('content', 'tree', hash('parent_node_id', 2, 'sort_by', array('attribute', false(), 'article/publish_date'), 'class_filter_type', 'include', 'class_filter_array', array('article'), 'limit', 5))}
{foreach $news as $new}
   <p><strong>Data: {$new.object.data_map.publish_date.content.timestamp|l10n('shortdate')}</strong>
   <br />
   <a href={$new.url|ezurl}>{attribute_view_gui attribute=$new.object.data_map.intro}</a></p>
{/foreach}

The outcome is pretty close to the desired one... but in this way what I get is the latest inserted articles, no the selected one!

Is there a way I can obtain, through a condition or a filter, the articles picked by a human? And how can I allow him to do so?

Thanks again!

loredanaebook.it

Gabriel Finkelstein

Friday 27 August 2010 9:45:43 am

What I do is not use the root as the homepage, but I create a new object under the root to act as the homepage. Although I don't know if you can do that using ezwebin.

You could instead add an objectrelationlist attribute to the homepage class, and relate them that way instead of trough adding locations.

Lo' F.

Saturday 25 September 2010 1:12:57 pm

"

In the frontpage.tpl file, inside /extension/ezwebin/design/ezwebin/override/templates/full/ (I use ezwebin extension), on the top of center-column, included an external file..

<div class="center-column-position">
            <div class="float-break center-column">
                <div class="overflow-fix">
                <!-- Content: START -->
{if $node.node_id|eq(2)}
  {include uri='design:content/primo_piano.tpl'}
{/if}
...

..which a created inside /extension/ezwebin/design/ezwebin/templates/content/...

<h2 class="primopiano">Primo Piano</h2>
{def $news=fetch('content', 'tree', hash('parent_node_id', 2, 'sort_by', array('attribute', false(), 'article/publish_date'), 'class_filter_type', 'include', 'class_filter_array', array('article'), 'limit', 5))}
{foreach $news as $new}
   <p><strong>Data: {$new.object.data_map.publish_date.content.timestamp|l10n('shortdate')}</strong>
   <br />
   <a href={$new.url|ezurl}>{attribute_view_gui attribute=$new.object.data_map.intro}</a></p>
{/foreach}

The outcome is pretty close to the desired one... but in this way what I get is the latest inserted articles, no the selected one!

"

.. I thought I could use attribute_filter .. so if they like an article to be displayed in the Highlights section they can select the "highlights" option through an article object attribute..

So I modified the original article class and added a selection attribute identified as "section_selection" where I listed the possible options: - none, - Primo piano, - other options..

Modified then the newly created primo_piano.tpl this way:

...
{def $news=fetch('content', 'tree', hash('parent_node_id', 2, 'sort_by', array('attribute', false(), 'article/publish_date'), 'class_filter_type', 'include', 'class_filter_array', array('article'), 'limit', 5, 'attribute_filter', array(array('article/section_selection', '=', "Primo piano"))))}

{foreach $news as $new}
...

but it doesn't work as it should...

Do you see where I might be wrong in here?!

..'attribute_filter', array(array('article/section_selection', '=', "Primo piano"))..

loredanaebook.it

Lo' F.

Saturday 25 September 2010 1:29:12 pm

Wait a second!.. The problem isn't in the script: by testing the attribute_filter with some other original article's attributes it works. So it seems as if the new added attribute "section_selection" is ignored..

Any clue?!

loredanaebook.it

Lo' F.

Saturday 25 September 2010 2:20:39 pm

I know it's Saturday night.. a very slightly chance to have somebody there thinking of sorting other programmers' eZ problems out...

Anyway..

I am almost there: I tried to change the string options into numbers: - empty, - 1, - 2,..

In this way the attribute_filter does what I want:

.. 'attribute_filter', array(array('article/section_selection', '=', 1))..

..even thoght the string is more suitable to my needs... Why a string shouldn't work?

Plus I might need to make this a little more flexible: I mean, the priority goes to the selected ones but, if no selection is made or less than the five I want to be there, 5 articles ordered by date have to be shown any way.

loredanaebook.it

Lo' F.

Sunday 26 September 2010 8:00:52 am

"

...the string is more suitable to my needs... Why a string shouldn't work?

"

Actually it does work. I slept on it and got the answer to my teeny-tiny "issue"..

Well, it doesn't matter what you have as an option, what it counts is its position!

So I mixed and matched the two:

Specified the more comprehensive options in the "section-selection" attribute as: - none; - Primo piano; - further options...

And filtered using its position number.. (which of course starts from zero):

..'attribute_filter', array(array('article/section_selection', '=', 1))..

....

Yet, got to go through the other thing..!

"

Plus I might need to make this a little more flexible: I mean, the priority goes to the selected ones but, if no selection is made or less than the five I want to be there, 5 articles ordered by date have to be shown any way.

"

loredanaebook.it

Lo' F.

Sunday 26 September 2010 9:26:21 am

"

...Yet, got to go through the other thing..!

Plus I might need to make this a little more flexible: I mean, the priority goes to the selected ones but, if no selection is made or less than the five I want to be there, 5 articles ordered by date have to be shown any way.

"

It might not be the right way to go but I kind of made up a working solution..!!

Here it is:

<h2 class="primopiano">Highlights</h2>
{def $news=fetch('content', 'tree', hash('parent_node_id', 2, 'sort_by', array('attribute', false(), 'article/publish_date'), 'class_filter_type', 'include', 'class_filter_array', array('article'), 'limit', 5, 'attribute_filter', array(array('article/section_selection', '=', 1))))}




<ul class="primopiano-list">


{def $counter=0}


{foreach $news as $new}

{set $counter= inc($counter)}
   <li><h3 class="data-info">{Date:{$new.object.data_map.publish_date.content.timestamp|l10n('shortdate')}</h3>
   <a href={$new.url|ezurl}>{attribute_view_gui attribute=$new.object.data_map.intro} &gt;&gt;&gt;</a></li>
{/foreach}



{def $limit = 5|sub($counter)}
{if $limit|gt(0)}
{def $more_news=fetch('content', 'tree', hash('parent_node_id', 2, 'sort_by', array('attribute', false(), 'article/publish_date'), 'class_filter_type', 'include', 'class_filter_array', array('article'), 'limit', $limit, 'attribute_filter', array(array('article/section_selection', '!=', 1))))}






{foreach $more_news as $one_more}
   <li><h3 class="data-info">{Date:{$one_more.object.data_map.publish_date.content.timestamp|l10n('shortdate')}</h3>
   <a href={$one_more.url|ezurl}>{attribute_view_gui attribute=$one_more.object.data_map.intro} &gt;&gt;&gt;</a></li>
{/foreach}
{/if}



</ul>

.... and solved!

loredanaebook.it

Nicolas Pastorino

Monday 27 September 2010 9:52:13 am

"

.... and solved!

"

Hi Lo'F, and thanks for sharing the solution.

You may want to mark the topic as solved (by clicking the grey ticker, at the left of the topic's title)

Cheers !

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Lo' F.

Monday 27 September 2010 10:20:42 am

"

Hi Lo'F, and thanks for sharing the solution.

You may want to mark the topic as solved (by clicking the grey ticker, at the left of the topic's title)

Cheers !

"

...Ok.. thanks for letting me know!

loredanaebook.it

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