Copy of a block in same page

Permalink 1 user found helpful
I have a block in one part of my page and as my page is responsive i want to show the content in another area.

My idea was to use stacks but i want the user to edit and have different things on each page.

so i have

$as = new Area('myBlock');
        $as->display($c);


and then in another part of the page i was thinking of say

$page = Page::getCurrentPage();
        $blocks = $page->getBlocks('myBlock');


but nothing comes in and if i echo $blocks I get the words array.

TMDesigns
 
juliandale replied on at Permalink Best Answer Reply
juliandale
I don't know how to display one specific block from an area within another part of the same page, but a simple trick is to simply have two editable areas with the same name. They will both show the same content and editing one will update the other, so all you'd need to do is hide or show the area relevant to the device they are viewing from.

Does that help?
TMDesigns replied on at Permalink Reply
TMDesigns
Thanks for that you must have read my mind.

I just tried it expecting an error and what do you know it works.

Thanks for you input.
juliandale replied on at Permalink Reply
juliandale
P.s. This isn't how I do my responsive designs, I avoid this 'duplicate areas' tactic wherever possible as it is not great for performance or page loading speeds (especially if a mobile device is loading all of the content and then displaying only part of it). However, I can see the benefit of it if you needed something normally displayed in the footer to be displayed in the header for a mobile device, such as a location map, store opening hours or something like that.
JohntheFish replied on at Permalink Reply
JohntheFish
If you don't want to have duplicate areas in your theme/page template:

You could use the built in block copy & paste which actually pastes a pointer to the original block.

You could also look at the Global Areas addon
http://www.concrete5.org/marketplace/addons/global-areas/...

Or my Universal Content Puller which can do the same and a lot more
http://www.concrete5.org/marketplace/addons/universal-content-pulle...

Use either to pull another area from the same page.

Or you could render the block once and use a snippet of jQuery to copy it to the other location in the browser.