Runar Ingebrigtsen
|
Wednesday 24 November 2004 3:30:25 am
I've got a news folder with several subfolders containing the actual articles. I'm trying to fetch the subfolders first, then the articles by doing a loop in a loop. I've just started understanding the template language, so I'm not perfectly capable of understanding everything yet. Am I thinking imperfectly here or am I just not getting the correct strings?
{let subfolder=fetch( content,
list,
hash( 'parent_node_id', 80,
class_filter_type, include,
class_filter_array, array( 'folder' )
)
)
}
{* Loop through all subfolders that we just fetched. *}
{section name=Sub loop=$subfolder}
{let children=fetch( content,
list,
hash( 'parent_node_id', $node.node_id,
class_filter_type, include,
class_filter_array, array( 'article' )
)
)
}
{* Loop through all articles that we just fetched. *}
{section name=Child loop=$children}
<li>
{* Display a link to the article. *}
<a href={$:item.url_alias|ezurl}>{$:item.name}</a>
</li>
{* End of loop. *}
{/section}
{/section}
{/let}
|
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}
|
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
|