Forums / Setup & design / List 8 articles, but 100 employees..

List 8 articles, but 100 employees..

Author Message

Valentin Svelland

Wednesday 30 July 2003 1:29:04 am

I've made a new class called "employees" for listing co-workers and their telephonenumbers and so on. However I can't list more than 8 of these employees in my line_employees.tpl.

I've tried to override my standard folder.tpl with a folder_class_16.tpl for this new employees-class but no luck so far.

I also must mention that my folder.tpl is rewritten to show article in full view if only one instance present in a given folder. If two or more they're listed using the corresponding line.tpl-file:

CODE FROM MY FOLDER.TPL :
---------------------
{* Now decide what to do *}
{switch name=decision match=$articles_count}

{* If only one article in folder: display this in full article view *}
{case match=1}
{* Show this if there is only one article! E.g. include the "full article view" page. *}
{section name=Article loop=$articles}
{node_view_gui view=full content_node=$decision:Article:item}
{/section}
{/case}

{* If two or more articles: display this according to "line_article.tpl"-view *}
{case}
{section name=Article loop=fetch(content, list, hash(
parent_node_id, $node.node_id,
limit, 8,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
class_filter_type, exclude,
class_filter_array, array( 1, 10 ) ) )}
{node_view_gui view=line content_node=$decision:Article:item}

{/section}
{/case}
{/switch}
----------------------

How do I list different number of elements from the articles and the employees classes?

Paul Forsyth

Wednesday 30 July 2003 1:44:03 am

Are you aware that your fetch statement contains a limit of 8 items to be returned? Remove this line if you are not bothered about the number coming back.

paul

Valentin Svelland

Wednesday 30 July 2003 2:08:57 am

Hi, I'm aware of that but I want a different limit for the two classes I mentioned.

Bjørn Kaarstein

Wednesday 30 July 2003 2:49:47 am

I think you'll have to use two different fetches to achive this.

First you fetch and display your eight articles, then you fetch and display your 100 employees. Each fetch with its own limit...

Regards Bjørn

Paul Forsyth

Wednesday 30 July 2003 3:23:10 am

Or you can use two {section} commands, one with a 'max' of 1 and the next with another size for 'max'. This means you can call the fetch once without a limit.

Look at the doco for section to see examples max in use.

paul

Valentin Svelland

Thursday 31 July 2003 12:26:19 am

My solution at this time is to do a section check for the particular node id for the page where I list my employees in the beginning of folder.tpl. Don't know if this is sexy coding, but at least it works.

FOLDER.TPL:
-------------------------

{section name=employee show=eq($node.node_id,204)}
<h1>Our employees - alphabetically</h1>
{section name=Article loop=fetch(content, list, hash(
parent_node_id, $node.node_id,
limit, 9999,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
class_filter_type, exclude,
class_filter_array, array( 1, 10 ) ) )}
{node_view_gui view=line content_node=$employee:Article:item}
{/section}

{section-else}

{* Get the articles (ClassID: "2"! Might be different for you!) *}
{let articles=fetch('content','list',hash(parent_node_id,$node.node_id,class_filter_type,"include",class_filter_array,array(2)))}

{* Get a count of the articles (ClassID: "2"! Might be different for you!) in this folder. *}
{let articles_count=fetch('content','list_count',hash(parent_node_id,$node.node_id,class_filter_type,"include",class_filter_array,array(2)))}

{* Now decide what to do *}
{switch name=decision match=$articles_count}

{* If only one article in folder: display this in full article view *}
{case match=1}
{* Show this if there is only one article! E.g. include the "full article view" page. *}
{section name=Article loop=$articles}
{node_view_gui view=full content_node=$decision:Article:item}
{/section}
{/case}

{* If two or more articles: display this according to "line_article.tpl"-view *}
{case}
{section name=Article loop=fetch(content, list, hash(
parent_node_id, $node.node_id,
limit, 8,
offset, $view_parameters.offset,
sort_by, $node.sort_array,
class_filter_type, exclude,
class_filter_array, array( 1, 10 ) ) )}
{node_view_gui view=line content_node=$decision:Article:item}

{/section}
{/case}
{/switch}

{/section}

Valentin Svelland

Thursday 31 July 2003 1:25:04 am

Why?? I was fooled to think this worked by cache..

Paul Forsyth

Tuesday 05 August 2003 2:58:59 am

Probably because you don't have a 'show' statement as part of your initial section. Also you complete the first section call with a {/section}. You need to put your {section-else} before the final {/section}.

Paul