Automatic Iframe creation

thet0olman - April 6, 2009 - 14:12
Project:insertFrame
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I would like to add a cck field where all the user has to do is specify the url of an external website and it will insert an IFrame of predetermined parameters. Is this something that might be simple to do?

#1

MarcElbichon - April 7, 2009 - 06:15

You can use contemplates in conjonction with CCK field to generate the body of the node with insertFrame tag.

#2

thet0olman - April 8, 2009 - 13:28

How might I acheive that code wise?

#3

thet0olman - April 9, 2009 - 19:59

So far I figured this much out:

<div class="field_myiframe">
  <h3>[Title]</h3>
  <iframe src="[URL]" scrolling="yes" width="100%" height="1200" frameborder="0" ></iframe>
</div>

where URL is the machine name of the cck field I want to use to create the Iframe but it doesnt work. How do I get the value of the url field into the iframe?

#4

MarcElbichon - April 10, 2009 - 16:19

Contemplate can do that.
You can also create a function youthemeègetURL($url) in your template.php.
In this function, get the cck field from database
and return the value

#5

thet0olman - April 10, 2009 - 18:19

Im sorry Im not familier with php functions and how to connect them to drupal
Might it possible you provide me some sample code?

Sorry I dont want to sound like i want you to do the work for me I just dont have a clue where to start to figure this stuff out

#6

MarcElbichon - April 20, 2009 - 08:20

Hi,

Sorry for the delay but i came back from holidays
The best way to do what you want is to use conTemplate, CCK and insertFrame.

  1. Download and unzip contemplates in your module directory
  2. Enable the module
  3. Backup your insertFrame.module and copy the new insertFrame module (see attached file) in the insertFrame directory. Rename it to insertFrame.module
  4. Create a new content type and add a text CCK field named for example insertFrame_url
  5. Click on template tab in the content type form
  6. In the body group, check Affect body ouput
  7. paste this code in the textarea (change cck fied as wanted)
    <?php
    print _insertFrame_getHTML($node->field_iframe_url[0]['view'])
    ?>
  8. You can now create a new node. In edit tab, type the iframe source url and see the result

The frame will be shown with default values (height & width =100%, ...). You can add CCK fields to customize it. The parameter of the _insertFrame_getHTML function is what you usually type without [[[ and ]]]. (ie : www.google.com height=300px).

If you want more details, please contact me by email.

AttachmentSize
insertFrame.module.txt 3.14 KB

#7

thet0olman - April 21, 2009 - 15:57

this worked great, I have one more question though, Is it possible to do a normal frame? where as the top would be my website and the botton would be an external website? instead of embeading it into the page as an IFRAME? I cant even seem to get it to work just by trying to code it into contemplate.

#8

MarcElbichon - April 22, 2009 - 06:48

What do you mean by normal FRAME ?
You can modify node.tpl.php of your theme (into theme/youtheme directory) to insert a frame for all the nodes of the site

#9

thet0olman - April 22, 2009 - 13:43

I ment like a frameset, I cant get drupal to show one when i modify node.tpl.php

#10

MarcElbichon - April 23, 2009 - 07:35

Could you contact me by email and explain exactly what you want to do ?

#11

MarcElbichon - May 12, 2009 - 07:46
Status:active» closed
 
 

Drupal is a registered trademark of Dries Buytaert.