Forums / Setup & design / How do I paginate an article/xml block?

How do I paginate an article/xml block?

Author Message

Wei Dai

Friday 26 September 2008 2:57:29 am

How I paginate an xml block content if an article is too long?

I used google and simple navigators before, but I knew they are used for paginate a list of nodes use offset.

What if I want to paginate an article to several pages if it is too long? Is there a template operator for this, like the one Joomla provides?

Or I can configure the navigators to do this?

Certified eZ Publish 4 developer looking for develop information & collaboration.

Richard Lundberg

Friday 26 September 2008 6:33:45 am

Use the article (Main Page) and article (sub page) classes. Place the sub pages under the main pages. This provides both an article menu and a "previous" "next" style navigators on each page.

www.peakm3.com

Sebastiaan van der Vliet

Friday 26 September 2008 6:44:13 am

Hi,

I tried getting this to work with a custom tag for the xml block. It might work, but you will need to test:

to content.ini.append.php, add the following lines:

[CustomTagSettings]
AvailableCustomTags[]=multipage
IsInline[multipage]=true

[multipage]
CustomAttributes[]=page

Create a template called 'multipage.tpl' in the folder: \design\[your_design_folder]\templates\content\datatype\view\ezxmltags\

Add the following code to the template 'multipage.tpl':

<!--page-->

Create a template called 'ezxmltext.tpl' in the folder: \design\[your_design_folder]\templates\content\datatype\view

Add the following code to the template 'ezxmltext.tpl':

{if $attribute.content.output.output_text|contains("<!--page-->")}
	{def $pages=$attribute.content.output.output_text|explode("<!--page-->")}
	
	{$pages[$DesignKeys:used.view_offset]}
	
	<hr>
	{def $object=fetch('content','object',hash('object_id',$attribute.contentobject_id))
	     $view_parameters=hash('offset',$DesignKeys:used.view_offset)}
	{include name=navigator
		uri='design:navigator/google.tpl'
		page_uri=$object.main_node.url_alias
		item_count=$pages|count
		view_parameters=$view_parameters
		item_limit=1}


{else}
	{$attribute.content.output.output_text}
{/if}

Finally, you would have to modify your existing article template so it displays (for example) only the body xml block, and no other attributes, when your offset is > 0.

How to use:
Go the the edit view for the page. Add a multipage custom tag wherever you want to start a new page.

Kind regards,
Sebastiaan

Certified eZ publish developer with over 9 years of eZ publish experience. Available for challenging eZ publish projects as a technical consultant, project manager, trouble shooter or strategic advisor.

zurgutt -

Tuesday 30 September 2008 12:57:57 am

One not so obvious but possibly easiest way is to not use separate pages at all but have whole article on one page and to use javascript to show/hide parts of it to create pagination effect. It is also much faster for the user and i doubt extra 0.1 seconds of initial page load time will be problem.

Certified eZ developer looking for projects.
zurgutt at gg.ee