Share » Forums » Install & configuration » Fetching articles from subfolders

Fetching articles from subfolders

Fetching articles from subfolders

Wednesday 24 November 2004 3:30:25 am - 3 replies

Author Message

Runar Ingebrigtsen

Wednesday 24 November 2004 4:20:23 am

Solved. :)

{* Fetch all subfolders, each representing a news category *}
{let subfolders=fetch( content,
	list,
		hash( 'parent_node_id', 80,
		class_filter_type, include,
		class_filter_array, array( 'folder' )
		)
	)
}
{* For each subfolder, fetch the articles *}
{section loop=$subfolders}
{let articles=fetch( content,
	list,
		hash( 'parent_node_id', $:item.node_id,
		class_filter_type, include,
		class_filter_array, array( 'article' )
		)
	)
}
	{* For each article, display the name and the url to the article and the category *}
	{section loop=$articles}
	<li>
		<a href={$:item.url_alias|ezurl}>{$:item.name}</a> - <a class="category" href={$:item.parent.url_alias|ezurl}>{$:item.parent.name}
	</li>
	{/section}
	{/let}
{/section}
{/let}

Martin Leblanc

Monday 20 December 2004 4:13:44 am

It helps if you indent the code correctly.... Then it's easy to see that a {/let} is missing.

Martin Leblanc

View this in Firefox: www.biocandy.dk/test.html

http://www.opensystems.dk
http://www.site-camp.net

Roy Bøhmer

Monday 20 December 2004 11:40:06 am

Agree with Martin, but fetching $node.node_id instead of $:item.node_id may caused more trouble than the missing /let ...
Personally I think it's easier to grasp the {section} when I use the var-attribute:

{section var=folder loop=$subfolders}
   Node-id of subfolder: {$folder.item.node_id}<br>
{/section}

Especially when doing nested loops I find this easier. There might be som drawbacks due to the namespace-stuff, but in case you had missed the var-feature at least check it out!

Good luck!
Roy

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu