Loading URLs into an iFrame

Permalink
I'm not a developer thought I'd start with that.

I have a site with links to external URLs, I'd like to pull those external URLs into an iFrame on another page in my site. Is there a way to do this automatically. I can create a page with iFrame for each link then link to that page I've created but its rather long winded.

Does anyone know of an efficient way to do this. Thanks in advance.

dhdesign
 
mesuva replied on at Permalink Reply
mesuva
Perhaps try using this plugin from the marketplace:
http://www.concrete5.org/marketplace/addons/dynamic-iframe/...

That should allow you to add your iframes as blocks. I haven't used this, but the auto-adjusting height looks like a really great feature.
dhdesign replied on at Permalink Reply
dhdesign
Thanks, I want to load a URL from an external domain so not sure this will work.

I currently have it working with the regular iFrame add on, so iFrame added as a block but I just don't want to have to add a page each time for each URL.
mesuva replied on at Permalink Reply
mesuva
Ah yes, I didn't notice the note about the url having to be the same domain. Sorry, it's getting late in the night for me and I didn't read your question properly either!

The only idea I have is to add a page attribute to the page, e.g. frame_url, and then in the page template, check to see if it has a value and if it does, output the code for an iframe.

This means you wouldn't have to add a block at all.
dhdesign replied on at Permalink Reply
dhdesign
Thanks for the answer but you've lost me and I don't follow. I may have to go off and read up on attributes but I am a designer and not tech.
mesuva replied on at Permalink Best Answer Reply
mesuva
No problems, I was a little bit vague.

You would first create a page attribute, 'frame_url', then edit one of your page type files to include this:

<?php 
$frame_url = $c->getAttribute('frame_url');
if ($frame_url) { ?>
<iframe src="<?php echo $frame_url; ?>"></iframe>
<?php } ?>


You could place this above your main area for example.

This doesn't set up any attributes for the iframe, such as the width as height, but that would just be a matter of editing the above tag or styling it up.

Then it means you could simply add your url in the page attribute for the page (through Properties, custom attributes, or you could look at setting up the composer). Then it should automatically create the iframe for you, putting in the url.
dhdesign replied on at Permalink Reply
dhdesign
Genius that works really well thank you, I have set it up in composer as well to make it even quicker. You still need to add a page for each URL but that saves alot of time

David