March 10 2010
While building chrismacpherson.com I came across a few issues when using AJAX techniques to deliver the content. One such issue is that because the URL isn’t really used, it makes returning to a specific page quite hard. For instance if you have an external link in an article and a reader clicks on it then when they return to the site it will just reset to the front page.
To stop this I introduced cookies to store the last viewed article details. The cookies are only valid for one hour so that the reader will see the front page most times they visit, but if they are going to and from this site regularly then they wont lose their place whilst doing so. I don’t think this is probably the best user-centric idea out there but that is not my concern for now. I’m just investigating how a site like this could work.
Anyway the ExpressionEngine cookie plugin that I found ‘cookie_plus’, was not suitable as it only allowed for one cookie at a time. I have modified the plug-in to allow multiple cookies to be called. Each cookie will be available to use in it’s own variable pair tag of the same name as the cookie.
So I can have the following:
{exp:cjm_cookies:get name="cookie1,cookie2" parse="inward"}
{exp:weblog:entries limit="1" weblog="{cookie1}" url_title="{cookie2}"}
{/exp:cjm_cookies:get}
Download the code here : cjm_cookies.zip
Comments