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

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

eZ debug

Timing: Jan 31 2025 04:14:34
Script start
Timing: Jan 31 2025 04:14:34
Module start 'layout'
Timing: Jan 31 2025 04:14:34
Module start 'content'
Timing: Jan 31 2025 04:14:34
Module end 'content'
Timing: Jan 31 2025 04:14:34
Script end

Main resources:

Total runtime0.0132 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.1563151.2109
Module start 'layout' 0.00450.0020 739.367236.6484
Module start 'content' 0.00650.0056 776.015698.1563
Module end 'content' 0.01210.0011 874.171941.9922
Script end 0.0131  916.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.001914.0969140.0001
Check MTime0.00096.5509140.0001
Mysql Total
Database connection0.00075.079010.0007
Mysqli_queries0.002720.414030.0009
Looping result0.00000.076110.0000
Template Total0.00086.310.0008
Template load0.00064.660310.0006
Template processing0.00021.580610.0002
Override
Cache load0.00043.337110.0004
General
dbfile0.002116.138080.0003
String conversion0.00000.030840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs