I've knocked up another quick and dirty fix. In this case, the client wanted to be able to break sections up into pages. I considered the previous/next section hack, but this wasn't appropriate. It wasn't important whether or not the products were loaded all at once, just that the client didn't want to view them all at once and have to scroll down them all.
So I've built a CSS/javascript fix that I thought I ought to share:
This should generate page links like "Pages 1 2 3 4" etc, and hide and show the relevant 'pages' using css. It allows the user to change the number of products shown per page.
So I've built a CSS/javascript fix that I thought I ought to share:
- Create a variable within the library called 'PageLength'. This represents the number of items per page. Do not allow an empty value. Set the place of setting to 'site'
- Within the product layout, apply an ID of 'listindex' to the containing element
- Within the product list, inside the 'start of list section' include the following:
Code:Pages: <script> pages = <actinic:variable name="ListCount" />/<actinic:variable name="PageLength" />; pagecount = Math.floor(pages)+(Math.ceil(pages)-Math.floor(pages)); for (i=1;i<=pagecount;i++) { links=" <a href=\"javascript:showpage("+i+","+<actinic:variable name="ListCount" />+")\">"+i+"</a> "; document.write(links); } </script>
- Wherever you keep your javascript code, add the following:
Code:function showpage(page,itemcount) { for (i=1;i<=itemcount;i++) { if(document.getElementById(i)) {document.getElementById(i).style.display = 'none';} } var top=page*<actinic:variable name="PageLength" />; var bottom=top-(<actinic:variable name="PageLength" />-1); for (i=bottom;i<=top;i++) if(document.getElementById(i)) { {document.getElementById(i).style.display = '';}} }
- add "showpage(1,9999)" to the onload event of the page to force it to show only the first page.
This should generate page links like "Pages 1 2 3 4" etc, and hide and show the relevant 'pages' using css. It allows the user to change the number of products shown per page.
Comment