TinyPortal

Development => Support => Topic started by: Halfhidden on March 02, 2009, 08:44:57 PM

Title: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 08:44:57 PM
OK... I'm new to Tiny Portal.... you'll guess by the style of my question :uglystupid2:
I've been looking through the forum and docs for a couple of days now and despite finding lots of information on the subject, I haven't actually been able to achieve a successful Iframe.
This is what I've been doing and hopefully after you've stopped laughing you can tell me where I've gone wrong. Before I start I should say that I'm very familiar with smf and coppermine (the reason for the iframe... I'm hoping to use G6's version) and right now I'm looking to abandon MKPortal in favour of Tiny.
I created an article (html) Pasted in G6's iframe code, named it and saved it to a previously created category. I activated the the article and then tested it but all I saw was a blank block on the front page. So thinking that I did that wrong I took the url from the magnifying glass in the category and pasted that into my browser but got the same.
Clearly I have no idea where or what I need to do to be able to wrap coppermine into Tiny Portal.... A lot of the instructions I've seen assume that you already have a good grasp of the portal...... I haven't yet and it's a little embarrassing to say the least.... as I pride myself on my ability to learn quickly.
Is anyone kind enough to guide me on this please? I am really impressed with what I see from TP... I only wish that I hadn't gone around the world looking at so many portals before trying this fantastic portal out.... its great!
Title: Re: Iframes... an easy question
Post by: Lesmond on March 02, 2009, 08:59:33 PM
I use the same code on my old site, but in a custom action, using the custom action mod from smf, I could never get it to work right in a article  :o here (http://www.lesmonds.co.uk/smf/index.php?action=gallery) is my gallery

<script type="text/javascript">

/***********************************************
* IFrame SSI script II- Ã,© Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids[i])
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</script>

<iframe id="myframe" src="http://www.your-site/cpg/index.php" marginwidth="0" marginheight="0" vspace="0" hspace="0" style="width: 100%; display: none;" frameborder="0" scrolling="no"></iframe>

Title: Re: Iframes... an easy question
Post by: Inny on March 02, 2009, 09:06:01 PM
Quote from: Lesmondâ„¢ on March 02, 2009, 08:59:33 PM
I use the same code on my old site, but in a custom action, using the custom action mod from smf, I could never get it to work right in a article  :o here (http://www.lesmonds.co.uk/smf/index.php?action=gallery) is my gallery

Weird, im using that script in every single article in my page that uses an iframe, i have around 30-40 articles like that. Can check it here (http://www.epu-wow.com/smf/index.php?page=PreviousPatchNotes).

All my articles had it before the <iframe> but i got fed up on copy/pasting the script so i decided to make it a proper .js file and call it from them index.template.

Both ways were working fine for me.
Title: Re: Iframes... an easy question
Post by: Lesmond on March 02, 2009, 09:15:58 PM
Quote from: Inny on March 02, 2009, 09:06:01 PM

All my articles had it before the <iframe> but i got fed up on copy/pasting the script so i decided to make it a proper .js file and call it from them index.template.

Interesting I would like to know how you done it that way?
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 09:18:26 PM
Thanks guys... but I'm still none the wiser... how do I achieve this.
Title: Re: Iframes... an easy question
Post by: ZarPrime on March 02, 2009, 09:20:49 PM
Lesmonds script works good for Coppermine since it will be located in your domain.  I think that one of the problems with iframes is that if the site you are calling into the frame is external to your site, it's hard to get it to show without scrollbars if height of the site you're calling can change dynamically, even if the height is set for the maximum size of the page.  If it's no problem to show the scrollbars, you can generally just use the iframe without the script.

Looke here ---> http://talesofthehavenexpanse.com/SMF-1/index.php/page,17.html

This is a test page I just created on one of my sites using a iframe in a php article, with all visual options unchecked (set to show with the Phobos theme).

The code to do it is here ...

echo '<iframe src="http://google.com/"
height="800" width="100%" Scrolling="yes"></iframe>';

Does this help to answer your question?

ZarPrime
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 09:29:56 PM
Thanks ZarPrime but the dynamic iframe is needed for my gallery as we have hundreds of comments placed under pictures. The problem so far is when a member goes from one picture to another they are left with massive amounts of scrolling up and down to cope with the comments. At the moment I have the Coppermine gallery ported to MKPortal, but this isn't supported by Coppermine and updates are difficult and time consuming.
I'm sure G6's code still works but I simply don't know enough of Tiny Portal to get it working at all :uglystupid2:
Title: Re: Iframes... an easy question
Post by: ZarPrime on March 02, 2009, 09:38:59 PM
Well, Lesmond may be able to better help you get it sorted out since he is certainly more familiar with using Coppermine in an iframe.

Sorry I wasn't of much help on this.

ZarPrime
Title: Re: Iframes... an easy question
Post by: Inny on March 02, 2009, 09:39:47 PM
Quote from: Lesmondâ„¢ on March 02, 2009, 09:15:58 PM
Quote from: Inny on March 02, 2009, 09:06:01 PM

All my articles had it before the <iframe> but i got fed up on copy/pasting the script so i decided to make it a proper .js file and call it from them index.template.

Interesting I would like to know how you done it that way?

Im sure you have notepadd++ or something similar. Copy the script, create new in notepad++, paste the sript there and save it as Javascript File(.Js). Upload the file in your server in a directory you like.

Open your index.template file and find:


<script language="JavaScript" type="text/javascript" src="' . $settings['default_theme_url'] . '/smooth.js?fin11"></script>'), '


Add after:


<script src="path_to_the_script" type="text/javascript"></script>


The code you should use after that in the HTML should just be:


<iframe id="myframe" src="externalpage.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0"></iframe>


Quote from: Halfhidden on March 02, 2009, 09:29:56 PM
Thanks ZarPrime but the dynamic iframe is needed for my gallery as we have hundreds of comments placed under pictures. The problem so far is when a member goes from one picture to another they are left with massive amounts of scrolling up and down to cope with the comments. At the moment I have the Coppermine gallery ported to MKPortal, but this isn't supported by Coppermine and updates are difficult and time consuming.
I'm sure G6's code still works but I simply don't know enough of Tiny Portal to get it working at all :uglystupid2:

Unfortunately i have that aswell because the iframe script will just get the height of the page that will first load. If you have links in the iframe, then the follow up page will just give you a big scrolling bar if the content is less.
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 09:51:28 PM
Thanks ZarPrime I appreciate your input 8)

Inny... I like the way this is done and I'll give it a go. It's just a pity about the dynamic resizing of frames as there can be a huge void between pictures if the script only adjusts the first call.
Wouldn't it be nice to call it as SSI's ;D (still I can dream on)
Title: Re: Iframes... an easy question
Post by: Inny on March 02, 2009, 10:04:07 PM
Quote from: Halfhidden on March 02, 2009, 09:51:28 PM

Inny... I like the way this is done and I'll give it a go. It's just a pity about the dynamic resizing of frames as there can be a huge void between pictures if the script only adjusts the first call.
Wouldn't it be nice to call it as SSI's ;D (still I can dream on)

Yeah tell me about it. Im suffering a bit from this and dying a bit inside when i have to scroll up.

Maybe you should try to find if theres a script or something to convert from coppermine to SMF Gallery. Im currently using SMF gallery PRO and you dont need to mess up with iframes and as far as i know SMF gallery is fully supported and will fit you fine if you decide to go with TP and SMF.

I dont have my SMF Gallery viewable for non-members but if you wanna check it out send me a PM to make you a temporary account.
Title: Re: Iframes... an easy question
Post by: Lesmond on March 02, 2009, 10:06:51 PM
Thanks Inny I will have to look into trying that out too!

@ Halfhidden lets us know how you get on with that, will try and help if you get stuck
Title: Re: Iframes... an easy question
Post by: Ken. on March 02, 2009, 10:13:32 PM
I didn't compare the code below to the one posted by Lesmondâ„¢ so it could very well be the same... in any case, it is the code currently in use for my cpg/iframe page in a TinyPortal HTML article.
You can see my page HERE. (http://www.ourfamilyforum.org/FamilyForum/index.php?page=45)

From everything that I've read over the past couple of years iFrames seem to always be problematic because of scroll issues (even with an 'auto-adjusting' script like this one) and also sometimes cause display issues in various browsers... my personal experience bears that out.
<script type="text/javascript">

/***********************************************
* IFrame SSI script II- ? Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["myframe"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
resizeIframe(iframeids)
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids] : document.getElementById(iframeids)
tempobj.style.display="block"
}
}
}

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
currentfr.style.display="block"
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)
}
}
}

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)
resizeIframe(iframeroot.id);
}

function loadintoIframe(iframeid, url){
if (document.getElementById)
document.getElementById(iframeid).src=url
}

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)
else
window.onload=resizeCaller

</script>  <iframe frameborder="0" scrolling="yes" style="width: 100%; display: none;" hspace="0" vspace="0" marginheight="0" marginwidth="0" src="http://www.FULL_PATH_TO)YOUR_CPG/index.php" id="myframe"></iframe>
Title: Re: Iframes... an easy question
Post by: ZarPrime on March 02, 2009, 10:18:15 PM
Quote from: Halfhidden on March 02, 2009, 09:51:28 PM
Thanks ZarPrime I appreciate your input 8)

Inny... I like the way this is done and I'll give it a go. It's just a pity about the dynamic resizing of frames as there can be a huge void between pictures if the script only adjusts the first call.
Wouldn't it be nice to call it as SSI's ;D (still I can dream on)

Unfortunately, this is a well known limitation when working with iframes.  Even if the iframe is set to auto-adjust, it only detects the height when the page is first accessed.  Perhaps, someday, somebody will find a way to use some sort of Ajax function to dynamically adjust an iframe as different pages are accessed.  As you say, we can all dream on. ;) :'(

ZarPrime
Title: Re: Iframes... an easy question
Post by: Ken. on March 02, 2009, 10:20:57 PM
Quote from: Inny on March 02, 2009, 10:04:07 PM
Quote from: Halfhidden on March 02, 2009, 09:51:28 PM

Inny... I like the way this is done and I'll give it a go. It's just a pity about the dynamic resizing of frames as there can be a huge void between pictures if the script only adjusts the first call.
Wouldn't it be nice to call it as SSI's ;D (still I can dream on)

Yeah tell me about it. Im suffering a bit from this and dying a bit inside when i have to scroll up.

Maybe you should try to find if theres a script or something to convert from coppermine to SMF Gallery.
Im currently using SMF gallery PRO and you dont need to mess up with iframes and as far as i know SMF gallery is fully supported and will fit you fine if you decide to go with TP and SMF.

I dont have my SMF Gallery viewable for non-members but if you wanna check it out send me a PM to make you a temporary account.

SMFHacks has a converter for cpg, but it currently is not working correctly. He has said that he is going to update/fix it at some point, but I don't know when that's to happen.
Dragooon has a very nice gallery as well and his is free. He has posted a converter for cpg (and for SMF Gallery) but I haven't tried it so don't know if it's completed or current.
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 10:24:33 PM
Thanks for the replies everyone.
@inny I have considered changing galleries but I have Stramm mod installed in Coppermine and this give members PM's within the gallery, avatars on comments, buddies list within the gallery, watermarks, instant notification of comments and much more. I've also invested in a guess game script.... so it's hard to find an act to follow Coppermine. The MKPortal port is absolutely fantastic and no scrolls are needed as the script calls SSI. But I'm the only one at the moment who is bothering to update the port with the latest versions of Coppermine. My fear is that if I stop the port will be abused and exploited as the Coppermine script will be out of date.

Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 10:27:50 PM
@Ken I looked at Dragons and noticed that it was about 12 versions behind the current build. I liked the way it was ported, but I worried about vulnerable scripts from CPG.
Title: Re: Iframes... an easy question
Post by: Ken. on March 02, 2009, 10:41:19 PM
For a long time I thought that cpg was THE best gallery available and in some ways still do think so, but for someone who is running SMF/TP I don't think that really holds up... not because of cpg, but because there is just no good way to include it in a SMF forum. Yes, I know that the bridge function offers a great way to tie the member base of SMF and cpg together, but after that it just will not work together well.

Although my cpg iFrame is still there I've stopped using it and even removed the links from my other pages.
Currently my forum uses SMF Gallery Pro, but I'll likely move to Dragooon's SMF Media Gallery (http://smf-media.com/community/index.php) soon.

On the versions for smg... he has only been working on it for a few months and has some more work to go on it, but it's also true that he has made tremendous progress and so I have no worries about changing over to use it sometime within the next couple of months.

EDIT: for spelling.
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 10:53:35 PM
@Ken I stand corrected. I thought you meant a different dragon who ported coppermine and hasn't updated his port or the coppermine scripts since version 1.3X... roughly 2006.
I can see the link you showed has promising features.
I agree that Coppermine are hell bent on fighting off any kind off port or integration.... its a real pity :(
Title: Re: Iframes... an easy question
Post by: Halfhidden on March 02, 2009, 10:55:53 PM
http://dragonflycms.org to be precise  8)