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.