News section only in the first page

Author Message

Pedro Barradas

Monday 12 April 2004 2:39:07 am

In the first page the news section have to appear, but when we click in other link of the first page it must hide. I only want it appear in the first page.How i do that?

Help me! Please.

Tanks

Alex Jones

Monday 12 April 2004 6:32:43 am

You could do this a couple of different ways.

1. Create an override template for your main node that includes the News. Then, in the template(s) used for the rest of the site, do not include the code to display the news section. If you are using a fetch to generate a navigation list, you will want to exclude the main node for the News section.

2. If you want to use a single template for the entire site, you could set up a section show block that will check which node is being displayed, and if the node happens to be your main one then it would display the news code, otherwise it would not display anything. An example:

I recommend you use the first choice as it should be more efficient.

Does this help?
Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Pedro Barradas

Tuesday 13 April 2004 3:23:09 am

I do a new template, using pagelayout, then i don't no how I make to link the first node (with news)!?

Alex Jones

Tuesday 13 April 2004 6:39:02 am

To retrieve the list of news articles you can use a fetch. Below is some example code that I took from http://www.ez.no/ez_publish/documentation/building_an_ez_publish_site/the_news_page/news_archive and modified slightly.

{* Grab all the news articles. *}
{let children=fetch( content,
                     list,
                     hash( parent_node_id, XXX,
                           sort_by, $node.sort_array,
                           class_filter_type, include,
                           class_filter_array, array( 'article' ) 
                         )
                    )
}
<table class="news_archive">
    <tr>
        <td>
            <b>Article:</b>
        </td>
        <td>
            <b>Published:</b>
        </td>
    </tr>
    {* Loop through all articles that we just fetched. *}
    {section name=Child loop=$children}
    <tr>
        <td>
            {* Display a link to the article. *}
            <a href={$:item.url_alias|ezurl}>{$:item.name}</a>
            <br />
        </td>
        <td>
            {* Display the date the article was published. *}
            {$:item.object.published|l10n(shortdate)}
        </td>
    </tr>
    {* End of loop. *}
    {/section}
</table>
{/let}

Note, you need to change the XXX in the fourth line of the example to the node ID of your news folder.

<b>Fetch Documentation:</b> http://ez.no/ez_publish/documentation/development/libraries/ez_template/operators/data_fetch
<b>Examples of Fetch:</b> http://ez.no/ez_publish/documentation/customization/tips_tricks/fetch_function_examples

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

John Mina

Tuesday 13 April 2004 7:24:30 am

Hey Alex
Thanks
That is good

Alex Jones

Tuesday 13 April 2004 7:54:08 am

Glad to hear it! The system can be a bit confusing at first, but the power behind it is great once you know how to use it.

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Pedro Barradas

Tuesday 13 April 2004 2:22:43 pm

thanks Alex, I'm going to try.Then I say something.

Pedro Barradas

Wednesday 14 April 2004 6:48:22 am

Alex, now I have two pagelayout.tpl, one with news, another without news. How i do to the first page be with news, and when we click in any link, the news dissapear??

Alex Jones

Wednesday 14 April 2004 8:41:24 am

Set up the template without the news code as <i>pagelayout.tpl</i> in <i>/design/YOURSITE/templates/</i>. Then set up an override just for your main page which uses the alternate template which displays the news (let's call it <i>main_pagelayout.tpl</i> for now). Here is an example of what should be in your override.ini.append for the site:

[main_pagelayout]
Source=pagelayout.tpl
MatchFile=main_pagelayout.tpl
Subdir=templates
Match[node]=2

The last line of that block tells the system that it should only apply <i>main_pagelayout.tpl</i> to your main node (which should have an ID of 2). All other nodes should use the default pagelayout template that you stored in <i>/design/YOURSITE/templates/</i>.

More info: http://ez.no/ez_publish/documentation/customization/custom_design/override_templates

Does that help?

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Pedro Barradas

Thursday 15 April 2004 6:39:27 am

Alex, thank you for all, it works!!
Thanks!

Alex Jones

Thursday 15 April 2004 7:58:41 am

You are very welcome. Glad to know you are up and running!

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Pedro Barradas

Thursday 15 April 2004 3:47:21 pm

Alex, a new question...if I want another first page (the initial page), with a flash animation, how I make this?

Alex Jones

Friday 16 April 2004 6:45:28 am

Well, you can override any node you want, so if you want another section header then follow the directions I posted above, but change the name of the file and the number of the node id you need to override.So, for example, your override will now contain:
[flash_pagelayout]
Source=pagelayout.tpl
MatchFile=flash_pagelayout.tpl
Subdir=templates
Match[node]=3

[main_pagelayout]
Source=pagelayout.tpl
MatchFile=main_pagelayout.tpl
Subdir=templates
Match[node]=2

Does this answer yoru question? Overrides provide a lot of flexibility. Say you wanted to use the pagelayout template that has Flash for all Articles (Class ID: 9 in this example) that are within your news folder (Node ID 23 in this example), you could use:
[flash_pagelayout]
Source=pagelayout.tpl
MatchFile=flash_pagelayout.tpl
Subdir=templates
Match[parent_node]=23
Match[class]=9

Just remember that as you add to your override.ini.append file, the more specific overrides should be listed towards the top of the template. So, if you are overriding the display of all folders (A), folders that are under the news folder (B), and one specific folder that happens to be under the News folder (C), the should be listed in your override file in this order:
(C)
(B)
(A)
Otherwise the most specific override (C) will be ignored, and thus will be styled via one of the other two choices, depending upon which is listed first in the file.

I hope this helps,

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Pedro Barradas

Sunday 18 April 2004 4:56:30 am

In the first page I have a flash movie, it works, the file .swf, is placed in c:\eZpublish\ezpublish\. Now i want to pu in the second page the same flash, because is a header.where i place the .swf file (the location)? Or there are another way to tell to ezpublish to do not process the swf files???

Help me Alex, my friend!

Alex Jones

Monday 19 April 2004 6:50:50 am

I replied to the other thread you posted on this same topic: http://ez.no/community/forum/setup_design/flash_problem_in_2_page

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Thursday 08 September 2005 12:53:17 pm

How do I modify this code to only fetch articles from the year 2004?

{* Grab all the news articles. *}
{let children=fetch( content,
                     list,
                     hash( parent_node_id, XXX,
                           sort_by, $node.sort_array,
                           class_filter_type, include,
                           class_filter_array, array( 'article' ) 
                         )
                    )
}
<table class="news_archive">
    <tr>
        <td>
            <b>Article:</b>
        </td>
        <td>
            <b>Published:</b>
        </td>
    </tr>
    {* Loop through all articles that we just fetched. *}
    {section name=Child loop=$children}
    <tr>
        <td>
            {* Display a link to the article. *}
            <a href={$:item.url_alias|ezurl}>{$:item.name}</a>
            <br />
        </td>
        <td>
            {* Display the date the article was published. *}
            {$:item.object.published|l10n(shortdate)}
        </td>
    </tr>
    {* End of loop. *}
    {/section}
</table>
{/let}

Kristof Coomans

Friday 09 September 2005 12:04:33 am

{let year=2004
     firstSecond=maketime(0,0,0,1,1,$year)
     lastSecond=maketime(23,59,59,13,0,$year)
     children=fetch( content,
                     list,
                     hash( parent_node_id, XXX,
                           sort_by, $node.sort_array,
                           class_filter_type, include,
                           class_filter_array, array( 'article' ),
                           attribute_filter, array( 'and', array( 'published', between, array( $firstSecond, $lastSecond ) ) ) 
                         )
                    )
}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Friday 09 September 2005 2:32:51 am

Thanks Kristof, the code worked great.
Problem solved :)

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