Variable into a snippet


I am using a snippet for pagination starting with the following lines

<?php $list = $page->children()->paginate(**6**); $pagination = $list->pagination(); ?>

Is there a simple way to change the number of page (here 6) depending on which template or which page the snippet is called ?
Thank you

You can use a variable, which you can then pass to your snippet:


$list = $page->children()->paginate($i);
$pagination = $list->pagination();

Then in your template:

<?php snippet('my-pagination-snippet', array('i' => 6)) ?>

You can pass variables to snippets like that:

<?php snippet('mysnippet', array('title' => 'Hello!')) ?>

EDIT: Too late :astonished:

Thanks a lot
and sorry for newbie question

We are here to answer your questions :slight_smile:. And weren’t we all newbies at one time or the other …