Forums / Developer / Navigate blog posts

Navigate blog posts

Author Message

Kim Bjurling

Tuesday 21 June 2011 1:56:40 am

Hi,
I want the users to be able to navigate between blog posts in the current blog post. Let me show you an example.
 __Blog
 |____ Post 1
 |____ Post 2
 |____ Post 3
 When the user is in Post 2, the user should be able to navigate to Post 1 and 3. In Post 2, there should be a navigatior that looks like this.
 <- Post1 Post3 --->

This is my code so far:

"

                                    {def $menu_count=fetch('content','list_count',
                                        hash( 'parent_node_id', 81))}
                                   
                                                                       
                                    {include name=navigator
                                    uri='design:navigator/simple.tpl'
                                    page_uri=concat('/content/view','/full/', $node.node_id)
                                    item_count=$menu_count
                                    view_parameters=hash(offset,10)
                                    item_limit=2}

"

I can not make this work. I can see the "Previous" link in Post 1 and Post 3. When I click on the link nothing happens.

If you hover the link you get this address
http://localhost/ez/index.php/content/view/full/<current id>

I am new in eZ Publish, so please be nice :)

Ivo Lukac

Tuesday 21 June 2011 2:56:38 am

Hi

Search for override/templates/full/gallery.tpl for example of code, it does the same thing...

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Kim Bjurling

Tuesday 21 June 2011 3:13:39 am

"

Hi

Search for override/templates/full/gallery.tpl for example of code, it does the same thing...

"

Alright, thanks :)

Kim Bjurling

Wednesday 29 June 2011 6:01:26 am

If someone looking after similar functionality like this, look into this code :)
The orginal code will you find in override/templates/full/images.tpl

"

{def $parent = $node.parent
$previous_item = false()
$next_item     = false()}
                                       
{if $parent.class_identifier|eq( 'blog' )}
                                   
{def $siblings = fetch( 'content', 'list', hash( 'parent_node_id',    $parent.node_id,
                                                                    'as_object', true(),
                                                                    'class_filter_type', 'include',
                                                                    'class_filter_array', array( 'blog_post' ),
                                                                    'sort_by',            array( 'attribute', false(),            'blog_post/publication_date' ),
                                                                                      'limit',              10000 ) )
                                          $index    = 0
                                          $node_id  = $node.node_id}
                                         
                                     {while is_set( $siblings[$index] )}
                                         {if $siblings[$index]['node_id']|eq( $node_id )}
                                             {if $index}
                                                 {set $previous_item = fetch( 'content', 'node', hash( 'node_id', $siblings[$index|dec]['node_id'] ))}
                                             {/if}
                                             {if is_set( $siblings[$index|inc] )}
                                                 {set $next_item = fetch( 'content', 'node', hash( 'node_id', $siblings[$index|inc]['node_id'] ))}
                                             {/if}
                                             {break}
                                         {/if}
                                         {set $index = $index|inc}
                                     {/while}
                                     {undef $siblings $index $node_id}

"

Cheers!

Nicolas Pastorino

Wednesday 29 June 2011 6:11:48 am

That is useful for others landing on this page/question. Thanks for this Sim.

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye