How many post in each page?

Author Message

Federico Canuti

Monday 07 November 2005 9:27:15 am

First of all, last time I didn't thank Lukasz Serwatka, so I do it now, your help has been precious.

Now I'm (still) working on a forum template and I want to give the registered users the possibility to decide how many threads or post per page they can see.
I've placed an integer attribut in the user class, now I can recall this value and put it in the correct template?
I believe the concerning code is:
{let page_limit=20
reply_limit=cond( $view_parameters.offset|gt( 0 ), 20,
19 )
I'v made some experiments writing numbers inside the template, now I have to take the correct value from my attribute?
How can I do it?

Łukasz Serwatka

Monday 07 November 2005 11:05:11 am

Hi Federico,

I'm glad that I could help you ;)

I your case you can use "User preferences", similar to admin interface, where you can set 10|25|50 objects per page. More about user preferences you can read here
http://ez.no/products/ez_publish_cms/documentation/incoming/user_preferences

Look also on template in admin interface e.g design/admin/templates/children.tpl You will find there example with ezpreference()

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Federico Canuti

Tuesday 08 November 2005 2:43:00 am

edit: I'll work on it, I'm trying to make it working for each integer (1-100)

Federico Canuti

Tuesday 08 November 2005 7:24:30 am

It looks like I've understood how it works but.. it doesn't work! I mean the links appear correctly and the system remember my selection but it doesn't change the visualization, even using the default template (and not mine) nothing happens.

Łukasz Serwatka

Tuesday 08 November 2005 7:46:08 am

Value from ezpreference will have to pass to fetch function as limit per page and to google navigator.

Something like

{let item_type=ezpreference( 'page_limit' )
     number_of_items=min( $item_type, 3)|choose( 10, 10, 25, 50 )
     list_count=fetch('content','list_count', hash( 'parent_node_id', $node.node_id ) )
     node_list=fetch( content, list, hash( parent_node_id, $node.node_id, limit, $number_of_items, offset, $view_parameters.offset ) )}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Federico Canuti

Tuesday 08 November 2005 8:51:25 am

Ops, now it doesn't work at all, Previously I was using this let section:

{let item_type=ezpreference( 'admin_list_limit' )
     number_of_items=min( $item_type, 5)|choose( 20, 1, 10, 20, 50, 100 )
     children_count=$node.children_count
     children=fetch( content, list, hash( parent_node_id, $node.node_id,
                                          sort_by, $node.sort_array,
                                          limit, $number_of_items,
                                          offset, $view_parameters.offset ) ) }

none of the two works correctly for me but the one you posted not even affected the "case" setting.

Łukasz Serwatka

Tuesday 08 November 2005 9:18:02 am

Display your children with {section} or {foreach}, depends which version of eZ publish do you use.

{section loop=$children var=child}
    {node_view_gui view=line content_node=$child}
{/section}

and include google navigator

{include name=navigator
         uri='design:navigator/google.tpl'
         page_uri=$node.url_alias
         item_count=$children_count
         view_parameters=$view_parameters
         item_limit=$number_of_items}

Enable DebugOutput and you will see all errors if exists.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Federico Canuti

Wednesday 09 November 2005 3:30:28 am

Sorry but it doesn't work for me, probably because I solved the situation from a different point of view or because I understand only a litte of eZ so far.
I worked on the default template (3.6.0) modifying it to my needs so i got the elements visualized by

          {section var=reply loop=$reply_list sequence=array( bgdark, bglight )}
               {let owner=$reply.object.owner owner_map=$owner.data_map}
                      <h4>{$owner.name|wash}</h4>
                       {$reply.object.data_map.message.content|simpletags|wordtoimage|autolink}
</let>
</section>

This is not all the code (obvious), in my navigator the last line is "item_limit=$page_limit}".
I don't know what is the problem but do there is a solution from my point of view?
I mean like I said before I can change the page_limit in the beginning of the template to match my needs, so if I can recall the right value from an attribute and use it here I believe I can solve the situation.

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 20 2025 05:49:30
Script start
Timing: Jan 20 2025 05:49:30
Module start 'layout'
Timing: Jan 20 2025 05:49:30
Module start 'content'
Timing: Jan 20 2025 05:49:30
Module end 'content'
Timing: Jan 20 2025 05:49:30
Script end

Main resources:

Total runtime0.0151 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.0055 589.1563152.6250
Module start 'layout' 0.00550.0034 741.781339.4453
Module start 'content' 0.00890.0043 781.226697.4453
Module end 'content' 0.01320.0019 878.671942.3047
Script end 0.0151  920.9766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002415.7186140.0002
Check MTime0.00117.1116140.0001
Mysql Total
Database connection0.00106.840510.0010
Mysqli_queries0.003523.146930.0012
Looping result0.00000.078810.0000
Template Total0.001510.210.0015
Template load0.00095.696510.0009
Template processing0.00074.473710.0007
Override
Cache load0.00064.018310.0006
General
dbfile0.00021.058980.0000
String conversion0.00000.033140.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