Embed one page in another (hidden, for popup, SEO)

Permalink
Hey guys,

I'm currently developing a custom block which is capable of opening Ajax contents in an modal popover.

Now, I'd like to optionally >>embed<< the desired target page contents to the current page to open them in a popup on demand.

The act of embedding is meant as search engine optimization.

Is it possible to get the rendered contents of a page within the view.php of my block so I can do a hidden output with it?

Thanks!

SlapY
 
PineCreativeLabs replied on at Permalink Reply
PineCreativeLabs
I would recommend taking a look at this FREE, useful block on how to do ajax stuff!

http://www.concrete5.org/marketplace/addons/ajax-lessons/...

Hope that helps?
JohntheFish replied on at Permalink Reply
JohntheFish
You could also use a combination of Blocks by Ajax (also by me) and a Global Areas block. Sometime you need to do a little template modification to get a specific response behaviour.

http://www.concrete5.org/marketplace/addons/blocks-by-ajax/...
http://www.concrete5.org/marketplace/addons/global-areas/...

Or maybe Tony's Rapid Ajax Paging
http://www.concrete5.org/marketplace/addons/rapid-ajax-paging/...
SlapY replied on at Permalink Reply
SlapY
Thanks guys!
But I actually know how to do AJAX pretty well :)

Seems like a little misunderstanding.

I've got a block, lets call it "Button_Hover".

This block has got two images for the button itself (default, hover) as well as fields for a page id and/or an external link.
Additionally, I've implemented some checkboxes for settings like IsLinked and IsPopup.

[edit]This block is already capable of fully blown AJAX magic.[/edit]

And NOW, because I'd like to embed various contents on our start page for search engine optimization, I came up with the idea of adding an IsEmbedded checkbox which should trigger the block to get the desired (rendered) contents of the target page and place them in a hidden container for my popup (ofcourse this is for internal popup links only and only a special case for the "home"-page).

Q: "But Slap, why the f would you do that?"
A: Because the target page should still be nicely editable.
A: Because I dont want to statically place the contents in a hidden div.
A: Because I dont want to create a new block
A: Because I thought it's pretty cool.

So the only thing I need, is a snippet to get the rendered content of a page "by page_id".

What I found so far, actually yesterday late evening, was:
$nh = Loader::helper('navigation');
$fh = Loader::helper('file');
$pageObj = Page::getById($PAGE_ID);         
$pageContent = $fh->getContents($nh->getLinkToCollection($pageObj, true));
echo $pageContents;


But I just copied it to my block real fast and had a quick look and it didn't seem to work. Diving into it now.

Any ideas are heavily appretiated!

Thanks ;)
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
Off the top of my head, the way the 'Global Areas' or 'Parent Areas' blocks get content from other pages is probably what you want without loading the style sheets and script from those pages (I have not looked at the code to confirm that).

In fact, if you are popping them up anyway and don't mind some occasional excess baggage, maybe just use a 'Global Areas' block with a display:none block style.

A more generic solution would be a combination of Magic Toggle (another of my addons) with a Global Areas block, but I expect you would rather code the behaviour yourself.

You could also look at 'getSearchableContent()' as a means of loading a blocks's content without any style or tags.
SlapY replied on at Permalink Reply
SlapY
Thanks for the hints! Directed me the right way.

I solved it using
$a = new Area("Content");
               $lnk_1_page = Page::getByID($lnk_id_1);
               $lnk_1_blocks = $a->getAreaBlocksArray($lnk_1_page);
               if(is_array($lnk_1_blocks) && count($lnk_1_blocks)) 
               {
                  $lnk_1_blocks = array_slice($lnk_1_blocks, 0, 6);
                  foreach($lnk_1_blocks as $b) 
                  {
                     $bv = new BlockView();
                     $bv->render($b);
                  }
               }


Thanks.