Author
|
Message
|
Alexander Davidsen
|
Thursday 19 July 2007 1:47:05 pm
Hi, I'm wondering how I can show the latest articles I have written in one of the columns on my frontpage. Is it possible to do this with out changing the pagelayout? If I have to change the pagelayout, how is this done? Thanks in advance :) - Alexander
|
paul bolger
|
Thursday 19 July 2007 8:16:24 pm
Hi Alexander It seems to have gone a bit quiet up in the northern hemisphere - hopefully this means the Ez crew are having some fun in the sun... But it's the middle of winter down here, so: The first step would be to override your pagelayout.tpl for your front page. (You can change the node assigned to the frontpage in site.ini (append.php)
[SiteSettings]
IndexPage=/content/view/full/373/
DefaultPage=/content/view/full/373
or whatever node you want... The override will look something like this:
[frontpagelayout]
Source=pagelayout.tpl
MatchFile=frontpagelayout.tpl
Subdir=templates
Match[node]=373
The override will need to be in the overrides/templates directory for your siteaccess. Make a copy of your pagelayout and put it there. Secondly, write a template to get the articles, take a look at the fetch documentation (reference section of the documentation). You may also need tree if you want to parse subdirectories. For heaps of examples look for the 'list' function http://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/content/fetch_functions/list After fetching the articles you'll need to work out what you want to display. http://ez.no/doc/ez_publish/technical_manual/3_9/templates/the_template_language/array_and_object_inspection and then use a foreach loop to display the items. I would recommend that you use a template include in your pagelayout (the override pagelayout, that is) to reference the template which does the actual fetch and display.
Paul Bolger
|
Alexander Davidsen
|
Friday 20 July 2007 5:11:17 am
Thanks for you reply, Paul.
I have now added this in settings/siteaccess/site and settings/siteaccess/eng in site.ini.append.php
[frontpagelayout]
Source=pagelayout.tpl
MatchFile=frontpagelayout.tpl
Subdir=templates Match[node]=2 and
[SiteSettings]
IndexPage=/content/view/full/2/ DefaultPage=/content/view/full/2 I have made a copy of pagelayout to extension/ezwebin/design/ezwebin/templates/override and renamed it to frontpagelayout.tpl. But this is still not working. When I turn on debug on the site, my frontpage are still using extension/ezwebin/design/ezwebin/templates/pagelayout.tpl. Does anyone know what can be wrong?
|
Alexander Davidsen
|
Friday 20 July 2007 6:15:28 am
I fixed the problem, some how.
I have now started to edit the frontpagelayout.tpl file and have added this:
{fetch( 'content', 'list',
hash( 'parent_node_id', 180, 'sort_by', array( 'published', false() ) ) )} This should show all the child articles of my articles page, but I only get the output "Array". What can be worng? Is the code trying to get the work items?
|
Alexander Davidsen
|
Friday 20 July 2007 7:02:46 am
Sorry for bumping this post alot, but i fixed my previous problem too. But I just found a new one. I want to add the "Latest articles" code to the center column of the main content. After what I can see the content are printed to the page via the function $module_result.content. How can I add code to this function, so the articles are printed in the center column? btw, this is the code I'm using:
{def $nodes=fetch( 'content', 'list',
hash( 'parent_node_id', 180,
'depth', 3 ) )}
{foreach $nodes as $node}
<a href="{$node.url}"> {$node.name|wash}</a> <br /> {/foreach}
|
paul bolger
|
Friday 20 July 2007 7:14:56 am
#I have now started to edit the frontpagelayout.tpl file and have added this:
#{fetch( 'content', 'list',
#hash( 'parent_node_id', 180, '#sort_by', array( 'published', false() ) ) )} You need to set a variable:
{def $myarticles=fetch( 'content', 'list',
hash( 'parent_node_id', '435',
'sort_by', array( 'priority', true() ),
'limit', '3'
))}
- or whatever - the syntax can be a bit tricky (watch out for quote marks and spaces being significant). Probably best to start without the sorting and limiting and put them in when you are sure the fetch is happening. Then do a foreach loop:
{foreach $myarticles as $article}
and then you can examine the attributes with:
{$article|attribute(show,2)}
and be sure to close the loop...
{/foreach}
You'll see that you can drill down through the objects to extract pretty well anything you need.
Paul Bolger
|
Alexander Davidsen
|
Friday 20 July 2007 2:43:52 pm
Hi again Paul, Thank you very much for your help. I solved this by adding this code to the frontpage.tpl override file.
{def $nodes=fetch( 'content', 'list',
hash( 'parent_node_id', 180, 'sort_by', published,
'depth', 1, 'limit', 3 ) )}
{foreach $nodes as $node}
<a href="{$node.url}"> {$node.name|wash}</a> <br />
{/foreach}
This works great, except sorting. Any idea on what I have done wrong?
|
paul bolger
|
Saturday 21 July 2007 7:03:05 am
Hi Alexander For the sorting try
'sort_by', array( 'modified', true() )
Paul Bolger
|
paul bolger
|
Saturday 21 July 2007 10:34:12 pm
# I want to add the "Latest articles" code to the center column of the main content. After what I can see the content are printed to the page via the function $module_result.content. Sounds like you are using the website interface. I think you need someone who has more experience with it to help you. From what I know what happens, roughly, is that a template like the one you have written can be 'embedded' - called by being included in an XML field. The frontpage content class has four XML fields; left, centre, right and bottom (or footer?). I'm not sure of the exact requirements for writing your own embedded template, and would be interested to read a definitive account of how this is done.
Paul Bolger
|
Alexander Davidsen
|
Sunday 22 July 2007 2:03:01 am
Hi again, Sorry, should have mention that I'm using ezweb. But I have found a solution on how to add this to the frontpage. This interface has a default set of overrides. So I just had to find the right override for the frontpage, witch was:
extension/ezwebin/design/ezwebin/override/templates/full/frontpage.tpl
And then I added this code to the template
{def $nodes=fetch( 'content', 'list', hash( 'parent_node_id', 180, 'sort_by', array( 'modified', false() ),
'depth', 1, 'limit', 10 ) )}
{foreach $nodes as $node}
<a href="{$node.url}"> {$node.name|wash}</a> <br />
{/foreach}
I don't know if this is a "dirty hack", but it works great:)
|
André R.
|
Monday 23 July 2007 2:46:00 am
Can't see any discussion about it here so I just want to add this: Alex seems to be running ezwebin (Website interface), in ezwebin you have special relations classes that can do all this for you. Just click the attachment icon, select existing content, browse and select the node that contains the articles, and choose 'itemized Sub items' from the Class droppdown, then click ok and your done. There are a couple of different styles as well(the ones in the Class droppdown menu), some more description can be found in the ezwebin user guide: http://ez.no/doc/extensions/website_interface
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|