Alpha pagination of objects

Alpha pagination of objects

Thursday 04 September 2003 12:51:27 am - 21 replies

Author Message

Paul Forsyth

Thursday 04 September 2003 1:14:56 am

Are you saying you have a way to return search results according to pagination, or that you have a problem with handling that many results?

For the size of results can you use the offset feature found in the advancedsearch scripts?

Paul

Bruce Morrison

Thursday 04 September 2003 2:19:51 am

Hi Paul

I'm after something like this
http://www.graduateopportunities.com/employers.php?id=D

In the admin section I want to have a single folder of contacts. In the user section I want to be able to display a "A....Z" navigation bar that when clicked on displays those contacts starting with the letter clicked.

The google navigator is used in the admin section to paginate child objects. This is great for browsing to a object but it can take several clicks to find the right page (and object).

In some cases it would be easier to be able to be able to alpha-page through these types of pages.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Paul Forsyth

Thursday 04 September 2003 3:04:28 am

Just noticed a typo in my post. I meant to ask if you *didn't* have a way of identifying which objects started with your letter of choice... Though i guess thats what you mean now.

Looking in the doco for fetch:

http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/data_fetch

With 3.2 you can return results from a fetch by attribute. Now, it is feasible to return a list of objects by pattern matching on their name, like so:

fetch( 'content', 'list',
--------hash( parent_node_id, <node to start search from>,
----------------attribute_filter,
-------------------------array( 'or', array( <attribute id>, '=', 'a*' ),
--------------------------------------array( <attribute id>, '=', 'A*' ) )
--------------)
-------)

Here <attribute id> is the class attribute. ez3.2 displays this number if you edit the class you wish to sort by...

Now, im not sure this will work, but its worth a try :)

Hope you see what im doing here.

paul

Paul Borgermans

Thursday 04 September 2003 4:14:08 am

Don't forget to add the class_filter too before specifying attribute ids

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Jakub Chromy

Monday 08 December 2003 12:13:17 pm

The code below works for selecting nodes which attribute nr. 181 begins with k.

Hix

{section loop=fetch( 'content', 'list', hash( parent_node_id, 1118 , attribute_filter, array( 'or', array( 181, '>=', 'k' ) )) ) }

<a href={$:item.url_alias|ezurl}>{$:item.name}</a><br>

{/section}

steve walker

Wednesday 07 September 2005 1:08:46 pm

Hi there,

I'm looking to implement this for the contacts folder on the Ez Intranet.

Before I start coding, I don't suppose any one has already created the form/fetch combination you need for this?

Thanks, Steve.

http://www.oneworldmarket.co.uk

steve walker

Thursday 08 September 2005 10:14:15 am

Hi,

I've got this half working with:

                {set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,                                                             offset, $view_parameters.offset,                                                             sort_by, $node.sort_array,
'attribute_filter', array( 'or', array( 'person/last_name', '>=', 'a' )), 			
limit, $page_limit ) )}

but the problem is that this fetches last_name that include 'a', not those that start with the letter 'a'.

I've tried wildcards 'a*' with no joy...

For me Jakub's code above doesnt work, tho' I'm building on 3.6 and his comment is from 2003...

Any ideas on this one?

Thanks, Steve.

http://www.oneworldmarket.co.uk

Kristof Coomans

Thursday 08 September 2005 11:31:30 pm

Since eZ publish 3.6, the fetch functions content/list, content/list_count, content/tree
and content/tree_count have been given extra filter functionality.

Maybe you can use the "like" filter operation:

{set list_items=fetch( content, list, hash(
    parent_node_id, $node.node_id,
    offset, $view_parameters.offset,
    sort_by, $node.sort_array,                                                                                                       
    attribute_filter, array( 
        'or',
        array( 'person/last_name' 'like', 'a%' ) 
        ),
    limit, $page_limit
    )
)}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

steve walker

Friday 09 September 2005 1:00:02 am

Kristof,

Thanks for your reply. I have tried with the 'like' op but with no success.

Some combinations I've tried are:

Returns no results:

'attribute_filter', array( 'or', array( 'person/last_name', '=', 'A%' ) ),

'attribute_filter', array( 'or', array( 'person/last_name', '=', 'A*' ) ),

'attribute_filter', array( 'or', array( 'person/last_name', '=', 'A' ) ),

'attribute_filter', array( 'and', array( 'person/last_name', '=', 'A*' ) ),

'attribute_filter', array( 'and', array( 'person/last_name', '=', 'A' ) ),

Returns everything:

'attribute_filter', array( 'or', array( 'person/last_name', '>=', 'A' ) ),

'attribute_filter', array( 'or', array( 'person/last_name', '>=', 'A%' ) ),

'attribute_filter', array( 'and', array( 'person/last_name', '>=', 'A%' ) ),

I just cant get it to filter by the first letter only :(

I'm wondering, do I need to use '=' and tweak the 'first-letter+wildcard' combination? I cant see any info on wildcards in docs or forum.

Steve.

http://www.oneworldmarket.co.uk

Kristof Coomans

Friday 09 September 2005 1:27:26 am

Can you paste the code you used with the "like" filter operation? Maybe there was an error in it.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Kristof Coomans

Friday 09 September 2005 1:33:55 am

I've made a mistake. The wildcard filter in the "like" filter operation is * instead of %.

So the correct code is:

{set list_items=fetch( content, list, hash(
    parent_node_id, $node.node_id,
    offset, $view_parameters.offset,
    sort_by, $node.sort_array,                                                                                                       
    attribute_filter, array( 
        'or',
        array( 'person/last_name' 'like', 'a*' ) 
        ),
    limit, $page_limit
    )
)}

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

steve walker

Friday 09 September 2005 2:04:07 am

Hi Kristof,

Sorry, still no joy I'm afraid... I've got:

                {set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,                                                             offset, $view_parameters.offset,                                                             sort_by, $node.sort_array,
'attribute_filter', array( 'or', array( 'person/last_name' 'like', 'a*' ) ),			
limit, $page_limit ) )}

but it doesnt return any results - it should return one. I tried the 'a*' as an 'A*' in case it was a caps issue.

Steve.

http://www.oneworldmarket.co.uk

Eivind Marienborg

Friday 09 September 2005 4:57:30 am

This works for me:

{default fra=$view_parameters.fom
         til=$view_parameters.to}


{let children=fetch( content, list, hash( parent_node_id, $node.node_id,                      attribute_filter, array('and',array(241,'>='$from),array(241,'<=',$to))))

You'll have to adjust 241 to your attribute, of course.

Kristof Coomans

Friday 09 September 2005 5:25:45 am

How does the configuration of your fetch alias looks like? You can find it in fetchalias.ini, under the group [children]. By default, it doesn't support the <i>attribute_filter</i> parameter, so you will need to change it, or make your own alias.

[filtered_children]
Module=content
FunctionName=list
Parameter[sort_by]=sort_by
Parameter[parent_node_id]=parent_node_id
Parameter[offset]=offset
Parameter[limit]=limit
Parameter[attribute_filter]=attribute_filter

I never use <i>fetch_alias</i> myself. For the particular things you are trying to do, I don't think it has any added value and you can use <i>fetch</i> instead.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

steve walker

Wednesday 14 September 2005 9:46:18 am

Hi,

Well, you have to laugh... Now I've got the reverse problem, have got the code giving results but it wont filter the results at all :)))

Kristof, your code needed an extra ',', so:

array( 'person/last_name' 'like', 'a*' )

is

array( 'person/last_name', 'like', 'a*' )

Now I get results returned, but it gives the whole list. The current fetch I have is:

 {set list_items=fetch_alias( children, hash( parent_node_id, $node.node_id,                                                             offset, $view_parameters.offset,                                                             attribute_filter, $time_filter,			 array( 'or', array( 'person/last_name', 'like', 'a*' )),                                                          sort_by, $node.sort_array,                                                             limit, $page_limit ) )}

Like I say, it just doesnt filter at all now :-/ I get a full set of results.

I've added the

Parameter[attribute_filter]=attribute_filter

into the fetch_alias files...

Any other thoughts on this conundrum?

Thanks, Steve

http://www.oneworldmarket.co.uk

Kristof Coomans

Wednesday 14 September 2005 11:11:39 pm

Indeed it needs the ',', I must have looked over that.

There's a problem with your attribute filter. The correct code is:

{set list_items=fetch_alias( children, hash(
        parent_node_id, $node.node_id,                                                  
        offset, $view_parameters.offset,
        attribute_filter, array(
            'and',
            $time_filter,
            array( 'person/last_name', 'like', 'a*'  )
            ),
        sort_by, $node.sort_array,
        limit, $page_limit
        )
    )}

 

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Christiane Kloss

Thursday 15 September 2005 2:42:38 am

Hi Steve,

I had the same problem once...
Read carefully...
'attribute_filter', array( [condition] )
'attribute_filter', array( 'person/last_name' 'like', 'a*' )
or
'attribute_filter', array( array( [logic], [condition1], [condition2] ) )

'attribute_filter', array( 'or', array( 'person/last_name' 'like', 'a*' ), [cond2] )...

so in your code [condition2] was missing completly.
But it looks like you don't need it at all.

Cheers Christiane

steve walker

Thursday 15 September 2005 7:27:31 am

Hi,

Kristof, your code worked :), though I had to remove the ' $time_filter,' to get it to work.

{set list_items=fetch_alias( children, hash(
        parent_node_id, $node.node_id,                                                  
        offset, $view_parameters.offset,
        attribute_filter, array(
            'and',
            array( 'person/last_name', 'like', $filter  )
            ),
        sort_by, $node.sort_array,
        limit, $page_limit
        )
    )}

The only issue I now have is I have to clear the cache every time the sorting value is changed, other wise the value of $filter doesnt change.

I'm going to post that in a seperate thread as its a slightly different subject - once I get it all working I'll post back the complete folder template code here.

Thanks for all the help!

Steve.

http://www.oneworldmarket.co.uk

steve walker

Thursday 15 September 2005 7:32:58 am

Just found this post:

http://ez.no/community/forum/general/probleme_with_a_href

Has the caching reolution...

http://www.oneworldmarket.co.uk

steve walker

Thursday 15 September 2005 8:16:10 am

Hi,

OK, here is the final code I have in the template to be used as a folder override for a contacts area:

{* Alpha Paginated Contact Folder - Full view *}
{set-block scope=root variable=cache_ttl}0{/set-block}
{let filter=first_set(ezhttp('filter',get),"all")}
{let ffilter=concat($filter,'*')}
 {switch match=$filter}
    {case match="all"}
 	  {set ffilter="*"}
    {/case}
    {case/}
    {/switch}
<div class="content-view-full">
    <div class="class-folder">

        <h1>{$node.object.data_map.name.content|wash()}</h1>

        
            <div class="attribute-short">
                {attribute_view_gui attribute=$node.object.data_map.short_description}
				<a href="?filter=a">A</a>&nbsp;|&nbsp;<a href="?filter=b">B</a>&nbsp;|&nbsp;<a href="?filter=c">C</a>&nbsp;|&nbsp;<a href="?filter=d">D</a>&nbsp;|&nbsp;<a href="?filter=e">E</a>&nbsp;|&nbsp;<a href="?filter=f">F</a>&nbsp;|&nbsp;<a href="?filter=g">G</a>&nbsp;|&nbsp;<a href="?filter=h">H</a>&nbsp;|&nbsp;<a href="?filter=i">I</a>&nbsp;|&nbsp;<a href="?filter=j">J</a>&nbsp;|&nbsp;<a href="?filter=k">K</a>&nbsp;|&nbsp;<a href="?filter=l">L</a>&nbsp;|&nbsp;<a href="?filter=m">M</a>&nbsp;|&nbsp;<a href="?filter=n">N</a>&nbsp;|&nbsp;<a href="?filter=o">O</a>&nbsp;|&nbsp;<a href="?filter=p">P</a>&nbsp;|&nbsp;<a href="?filter=q">Q</a>&nbsp;|&nbsp;<a href="?filter=r">R</a>&nbsp;|&nbsp;<a href="?filter=s">S</a>&nbsp;|&nbsp;<a href="?filter=t">T</a>&nbsp;|&nbsp;<a href="?filter=u">U</a>&nbsp;|&nbsp;<a href="?filter=v">V</a>&nbsp;|&nbsp;<a href="?filter=w">W</a>&nbsp;|&nbsp;<a href="?filter=x">X</a>&nbsp;|&nbsp;<a href="?filter=y">Y</a>&nbsp;|&nbsp;<a href="?filter=z">Z</a>&nbsp;|&nbsp;<a href="?filter=all">show all</a>
            </div>
       

        {section show=$node.object.data_map.description.content.is_empty|not}
            <div class="attribute-long">
                {attribute_view_gui attribute=$node.object.data_map.description}
            </div>
        {/section}
{*Shows all attributes of current node }

{let node=fetch(content, list, hash(limit, 6, parent_node_id, 2, depth, 3, sort_by,array(published,false()), class_filter_type, include, class_filter_array, array(article)) )}
{$node|attribute(show) *} 

{section show=or($node.node_id|eq(2)) }
 {include uri="design:content/advancedsearch.tpl"}
{/section}

        {section show=is_unset( $versionview_mode )}
        {section show=$node.object.data_map.show_children.content}
            {let page_limit=10
                 list_items=array()
                 list_count=0}

           
                 {set list_items=fetch_alias( children, hash(
        parent_node_id, $node.node_id,                                                  
        offset, $view_parameters.offset,
        attribute_filter, array(
            'and',
            array( 'person/last_name', 'like', $ffilter  )
            ),
        sort_by, $node.sort_array,
        limit, $page_limit
        )
    )}
															 
                {set list_count=fetch_alias( children_count, hash( parent_node_id, $node.node_id ) )}
            

            <div class="content-view-children">
                {section var=child loop=$list_items sequence=array(bglight,bgdark)}
                    {node_view_gui view=line content_node=$child}
                {/section}
            </div>
{*section show=or($node.object.section_id|eq(6), $node.object.section_id|eq(7)) }
 {include uri="design:content/advancedsearch.tpl"}
{/section*}

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

        {/section}
        {/section}

    </div>
</div>
{/let}
{/let}

I havent tested this extensively, but it seems to be working fine.

Once again, thanks for the help on this.

Regards, Steve.

http://www.oneworldmarket.co.uk

You must be logged in to post messages in this topic!

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