Path

ez.no / ezpublish / documentation / customization / tips & tricks / splitting an article over several pages


Splitting an article over several pages

These documentation pages are no longer maintained. Please visit the new documentation site.

This can be accomplished using a custom Article Page class as a child of an Article class.

Creating the Article Page Class
First create your new Content class and name it Article Page.
Set the identifier to article_page

Add an Integer datatype and name it Page Number
Set the identifier page_num
Mark it required. I did not specify a min max or default.

Add an XML Text Field datatype and name it Body
Set the identifier to body
Set it as searchable
Set preferred number of rows to 20

Store the class.

Finally, make sure that the anonymous role has read access to the newly generated content class.

Modifying the Templates
Go to: /design/your_site_design/override/templates
Open article.tpl in a text editor:
Add the following lines where you want the pages listed:

{* Subpages *}

{let page_list=fetch(content,list,hash(parent_node_id,$node.node_id,

sort_by,array(array(name)),

class_filter_type,include,

class_filter_array,array('article','article_page')))}

 

{section show=$page_list}

<h2>Pages</h2>

Page: <a href={$node.url_alias|ezurl}>1</a> | 

{section name=Page loop=$page_list}

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

{/section}

{/section}

{/let}

In the default article-view-template in the admin interface the new-menu is hidden. Make it show again by removing the comment code. It should look like this in /design/admin/override/templates/article.tpl:

<div class="buttonblock">

   {switch match=$content_object.can_create}

   {case match=1}

       <input type="hidden" name="NodeID" value="{$node.node_id}" />

       <select name="ClassID">

       {section name=Classes loop=$content_object.can_create_class_list}

           <option value="{$:item.id}">{$:item.name|wash}</option>

       {/section}

       </select>

       <input class="button" type="submit" name="NewButton" value="{'Create here'|i18n('design/standard/node/view')}" />

   {/case}

   {case match=0}

   {/case}

   {/switch}

</div>

Create an Article
Start by creating a regular Article. Add an intro and some content. This will be your first page. Store your Article.

Adding a New Page
Click on the newly created Article. Use the new-menu you made visible to create an Article Page.

Now enter the number of this page. In this case 2.

(If you accidentally make two page 1s or two page 2s it will not break anything but your navigation will be pretty confusing. If anyone knows how to have a class autoincrement itself based on its sibling classes feel free to post the solution here)

Fill in the body of your second page and save your changes.

More pages can be added in the same manner.

Possible problems
If it is not working check to make sure you created your new pages in your original Article class. If you put them somewhere else they will not appear in the page listing.

Comments

Working in 3.5 or later- allowing a child of the article class

If you have trouble assigning children to the article class, you may also need to modify the article class to make it a container.

Example no longer valid

This method of pagination is no longer valid as you can not have articles as child nodes of artciles.

Instead use this example:
http://www.ez.no/ez_publish/docum...stomization/custom_design/pagination

Wrong full_class_2.tpl in 3.1-1?

In version 3.1-1 the template full_class_2.tpl only consits of three lines

<h1>{attribute_view_gui attribute=$node.object.data_map.title}</h1>
{attribute_view_gui attribute=$node.object.data_map.intro}
{attribute_view_gui attribute=$node.object.data_map.body}

So, where should I do the changes?

Contents

Customization

Access control
eZ publish API Documentation
Content structure
Custom design
Components
Tips & Tricks
    Debugging templates
    Javascript in templates
    Fetching current user
    Showing related objects
    Show which templates are used
    Fetching the ID of the parent
    One Article Folder
    Creating tree menus
    How can I use my own php script insid...
    Hiding attribute content
    Splitting an article over several pages
    Accessing section id in pagelayout
    List articles in folder
    Creating nice URLs
    Alt tag on images
    Improve the pagelayout.tpl
    Clean HTML tags
    Insert javascript call inside ezpub d...
    3rd party applications
    Fetch Function examples
    Display more than 15 items on your co...
    Including PHP files in templates
    Redirecting after content publishing
    HowTo see if article has an image
    Date and Time Formats
    Forms processing example: store user...
    Adjust Timezone
    Adding a Remove Button/Image
    Find the age in years for an object
    Editing, creating and removing conten...
    Indexing binary files with IFilters o...
Troubleshooting


Created

05/05/2003
8:53:13 pm
by James Ward

Last updated

11/01/2004
9:54:53 pm
by Anders F

Authors

James Ward
Stuart Fenton
Bård Farstad
Anders F



This page is part of the eZ Publish documentation. The documentation is available under the GNU Free Documentation License. All contributions will be released under the terms of this license.