Pass value from a block to the footer.

Permalink
Is there a way to pass a value from a block and make it available to the page footer ? I have a block that gets some data from a 3rd party API. Some of that data needs to be available to the page footer when it renders. Can I temporarily store this data in the current page or view somewhere ? And no, it's not just a matter of calling setFooter or setHeader from the block for this particular situation.

Thanks,

Warren

warish
 
warish replied on at Permalink Reply
warish
Ok, I am placing the values in the $_REQUEST array which feels really dirty. Can someone tell me how bad that is and give me a better place to temporarily store these values ?

Thanks,

Warren
WillemAnchor replied on at Permalink Reply
WillemAnchor
Why not store it in a hidden input html tag in the block, and retrieve it in the footer ?
$this->set() from the block controller might even work, but I'm not sure about the scope.
warish replied on at Permalink Reply
warish
Excuse my ignorance, but how do I get the values back out of the hidden fields once I am in the footer, jQuery ?
WillemAnchor replied on at Permalink Reply
WillemAnchor
yes, if you take that route.
Probably need to put it inside a document ready, something like:
$(document).ready(function () {
   var myval = $('#myselector').val();
})
WillemAnchor replied on at Permalink Best Answer Reply
WillemAnchor
ah, sorry
I said footer, but meant block/view.php

no need to change any theme files then.

add a bit of javascript to the view, to retrieve the value from the hidden input, and insert it wherever you want.

----

If you do change your theme...then I would just handle it within the theme