Greetings,
This is my very first plugin, so please if there are any faults in the code or anyone has any suggestions for improvement or features then please let me hear them
.
Basically this plugin makes it easy to implement a non-refresh pagination for your weblog entries. You can tell it how many entries it should list per page.
Updates
V 1.3
- Fixed a potential bug for people not removing index.php from their URLs.
V 1.2
- Updated code to make it actually work, doh! ><
V 1.1
- Added several checks to make sure the syntax is used properly.
- Added two more optional parameters called “prev_class” and “next_class”. These are used to define the CSS class of each link.
- Made “prev_link” and “next_link” conditionals as well so you can check to see if they are set. Check example below to see how I’ve used them.
- Made “limit” parameter optional and if left blank, it will default to 4 entries per page.
- Updated usage section.
V 1.0
- Initial Concept
Usage
:: Setup ::
1) Create your main template where your entries will be shown. This is where you Holder <div> needs to be located and inside that Holder <div> you need to embed the AJAX template. Also jQuery 1.2.6 needs to be included in the header tags. An example will be shown below.
2) Create your AJAX template for the ajaxification (real word?) to take place. Make sure in your {exp:weblog:entries} tag you include limit=”{limit}”, offset=”{offset}” and dynamic=“off”. Again, example will be shown below.
:: Parameters ::
These parameters must not be blank:
weblog - Define which weblog you are pulling entries from.
template - The full url to your Ajax Template
holder - Define what <div> on your main template is going to hold the entries.
parse - This needs to be set to “inward” for the plugin to work.
These parameters are optional:
limit - Define how many entries should be shown per page. Default is 4 if left blank.
next - Define exactly how you want the “Next” text to look. Default is “Next >>” if left blank.
prev - Define exactly how you want the “Prev” text to look. Default is “<< Prev” if left blank.
next_class - Define the CSS class you want to use for the Next link. Default is class=”” if left blank.
prev_class - Define the CSS class you want to use for the Prev link. Default is class=”” if left blank.
:: Variables ::
The plugin will not work if any of these variables are missing in your template.
{prev_link} - This gets replaced by the Previous Link. Can also be used as conditional. Example below.
{next_link} - This gets replaced by the Next Link. Can also be used as conditional. Example below.
{limit} - This tells the {exp:weblog:entries} tag how many to show each page as told by the “limit=” parameter above.
{offset} - This tells the {exp:weblog:entries} tag how many entries to offset.
:: Barebones Example Usage ::
Main Template:
<div class=“codeblock”>
<html></div>
<head>
< script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" >< /script >
</head>
<body>
<div id="wrapper">
<div id="body">
<h1>This is an example for AJAX Pagination</h1>
<div id="ajax_content">{embed="template_group/ajax_template"}</div>
</div>
</div>
</body>
</html>
AJAX Template:
{exp:ajax_pagination weblog="weblog" limit="4" template="{site_url}template_group/ajax_template" holder="ajax_content" parse="inward"}
{prev_link} {if prev_link && next_link}|{/if} {next_link}
{exp:weblog:entries weblog="weblog" disable="pagination|member_data|trackbacks" limit="{limit}" offset="{offset}" dynamic="off"}
<h3>{title}</h3>
{body}
{/exp:weblog:entries}
{/exp:ajax_pagination}
