You can get EE to write the variable into the JavaScript on the page,
before the browser ever sees it. Here’s how I would do that in raw
PHP, you can translate into EE tags:
<!-- somewhere inside the page head,
after the libraries are loaded -->
<script type="text/javascript">
document.observe('dom:loaded',function(){
var this_page = <?php echo $entry_id; ?>;
var arr = (Cookie.get('myHistory')) ?
Cookie.get('myHistory').split('|') : [];
arr.push(this_page);
Cookie.set('myHistory',arr.join('|'));
});
</script>
That block of code would rely on the page already including the three
required script libraries, and if you want to use Protaculous for
this, you would drop the outer document.observe block, since the
Action writes that for you.
What this does is set an observer on the page, which is similar to
doing onload=“whatever()” in the body tag. The difference is that you
can have multiple observers on the same event, and they stack and
don’t block each other.
So because my PHP code wrote whatever the current value of $entry_id
was into the JavaScript before the JavaScript ever reached the browser
(i.e.: back inside the server while the page was being assembled),
when the browser evaluates the JavaScript, there is an actual value
already written into the JS and that gets used to append to your
history string.
Walter
On Oct 14, 2010, at 6:02 AM, ummedia wrote:
Thanks Walter I have spent some time looking at the code, it does
exactly what I want but it is just taking some time for it to sink
in. How do i get it to set the cookie when the page loads using the
existing cookie and adding the {entry_id} of the existing page. I
can do the entry id bit using EE tags its the javascript I am not
familiar with.
thanks as usual
Adam
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options
dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options