Created
October 12, 2012 16:40
-
-
Save jeromecoupe/3880163 to your computer and use it in GitHub Desktop.
Custom pagination with {exp:stash:get_list} and filtering
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!-- Wrapper template --} | |
{embed="wrappers/page_full_width"} | |
{!-- Meta data --} | |
{exp:stash:set name="meta_title"}Our projects{/exp:stash:set} | |
{exp:stash:set name="meta_description"}Projects of the International Polar Foundation{/exp:stash:set} | |
{!-- Navigation --} | |
{exp:stash:set name="nav_current"}projects{/exp:stash:set} | |
{!-- lists of projects (highlighted projects first) --} | |
{exp:channel:entries disable="categories|category_fields|member_data|trackbacks" channel="projects" orderby="cf_project_highlight|date" sort="desc|desc" dynamic="no" status="not closed"} | |
{exp:stash:append_list name="projects_list"} | |
{stash:st_project_title}{title}{/stash:st_project_title} | |
{stash:st_project_highlight}{cf_project_highlight}{/stash:st_project_highlight} | |
{stash:st_project_url_title}{url_title}{/stash:st_project_url_title} | |
{stash:st_project_img}{cf_project_img}{/stash:st_project_img} | |
{stash:st_project_summary}{cf_project_summary}{/stash:st_project_summary} | |
{/exp:stash:append_list} | |
{/exp:channel:entries} | |
{!-- Create Primary Content--} | |
{exp:stash:set} | |
{stash:primary_content} | |
{!-- Page title and intro --} | |
<div class="page_header"> | |
<h1 class="main_title">{lv_projects_title}</h1> | |
<div class="intro"> | |
{lv_projects_intro} | |
</div> | |
</div> | |
{!-- limit for stash_get loop and current page in list --} | |
{stash:st_limit}3{/stash:st_limit} | |
{stash:st_offset}{if segment_3}{segment_3}{if:else}0{/if}{/stash:st_offset} | |
{!-- Build projects list (highlighted first) --} | |
{exp:stash:get_list name="projects_list" prefix="stashprefix" parse_tags="yes" parse_conditionals="yes" limit="{exp:stash:get name='st_limit'}" offset="{segment_3}" match="#^n$#" against="st_project_highlight" parse="inward"} | |
{!-- Blocking out </li><li> to avoid white-space between inline-block list items --} | |
{if count == "1"}<ul class="projectslist"><li>{/if} | |
<p class="imgholder"><a href="/partials/project/{st_project_url_title}">{exp:ce_img:pair src="{st_project_img}" width="700" height="394" crop="yes|center, center"}<img src="{made}" alt="{title}" />{/exp:ce_img:pair}</a></p> | |
<h2><a href="/partials/project/{st_project_url_title}">{st_project_title}</a></h2> | |
<p>{exp:eehive_hacksaw words="30" append="..."}{st_project_summary}{/exp:eehive_hacksaw}</p> | |
{if count == total_results}</li></ul>{if:else}</li><li>{/if} | |
{if count == total_results} | |
<p>Absolute count: {absolute_count} - Absolute results: {absolute_results} - limit: {stash:st_limit}</p> | |
{if absolute_count < absolute_results} | |
<p><a href="{site_url}/partials/projects/{absolute_count}">next page</a></p> | |
{/if} | |
{if (absolute_count > stash:st_limit) && (segment_3 != 0)} | |
{if "{exp:mx_calc expression='{absolute_count} - ({stash:st_limit} * 2)'}" > 0} | |
<p><a href="{site_url}/partials/projects/{exp:mx_calc expression='{absolute_count} - ({stash:st_limit} * 2)'}">previous page</a></p> | |
{if:else} | |
<p><a href="{site_url}/partials/projects/0">previous page</a></p> | |
{/if} | |
{/if} | |
{/if} | |
{/exp:stash:get_list} | |
{/stash:primary_content} | |
{/exp:stash:set} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mark now has a feature branch of stash supporting pagination in {exp:stash:get_list}