It is currently Mon Jul 21, 2025 9:24 pm



Reply to topic  [ 8 posts ] 
phpinclude and/or iFrame issues 
Author Message
Minor Diety
User avatar

Joined: Fri Apr 11, 2003 5:09 pm
Posts: 4004
Location: Walsall, West Mids, UK
Reply with quote
Post phpinclude and/or iFrame issues
Right, first off I know iFrames suck, but I may HAVE to use one here.

here's the website

http://www.d-mas.co.uk

here's the page I want to display as inserted in to the main page

http://www.d-mas.co.uk/blog

The problem is this:

When I use an iFrame, it inserts the page correctly formatted with all the trimming just the way I like it. the only problem, is it has scroll bars on the right, and you have to scroll down the blog individually to the rest of the website.

If I use phpinclude, it inserts the page without the scroll bars, however, it's the right length and everything.

I need to somehow merge the two. I need the fact that the iFrame inserts all the correct formatting (as the blog/index.php is getting it's formatting from it's own directory, you see) but It also needs to account for the fact the blog can be any length, depending on how much news there is and how long the last 5 posts are.

Where do I start?!

_________________
Games to complete:
GTA IV [100%] (For Multiplayer next!)
Fallout 3 [50%]
Rock Band [35%]
http://www.cafepress.com/SmeepProducts


Tue Jul 22, 2008 12:14 pm
Profile WWW
Emperor
User avatar

Joined: Wed Apr 16, 2003 1:25 am
Posts: 2560
Reply with quote
Post 
When you include the page B (http://www.d-mas.co.uk/blog/) on PHP level to the page A (http://www.d-mas.co.uk/), formatting sucks because you use relative address(es) to link CSS in the page B. Make it absolute and it will start loading everywhere else. Still it won't be a neat solution because it would load B's headers and all stuff into the page A that already has its own. You need to bypass it.

What you can do is to separate page B into "headers and footers" and "content" and then load them in a proper oder.

A rough illustration: blog/index.php
Code:
<?
include "headersforB.php";
include "content.php";
include "footersforB.php";
?>


Now, you'd just need to update CSS in the page A a bit (to load the stuff that page B uses) and just to load the "content" part from page B into A.

A rough illustration: index.php
Code:
<?
include "headersforA.php";
include "blog/content.php";
include "footersforA.php";
?>


I'd never use iframe for this.

_________________
++


Last edited by RB on Tue Jul 22, 2008 1:04 pm, edited 1 time in total.



Tue Jul 22, 2008 1:02 pm
Profile WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16701
Location: On a slope
Reply with quote
Post 
javascript.

Using javascript you can automatically resize the iframe to the size of its contents.

Ok, so basically we need to put an onload handler on the iframe so that when it loads, it triggers the javascript.

<iframe onload='resizeIframe()' src='whatever'></iframe>

The magic of course happens in the javascript function. This kinda works and should give you a basic idea

<script type='text/javascript'>
function resizeIframe(el){
//get the dimensions of the iframe's contents
el.style.width = this.document.body.scrollWidth + 'px';
el.style.height = this.document.body.scrollHeight + 'px';
}
</script>

el references the iframe tag... thus i'm setting with css width and height on the tag. 'This' references the iframe contents, and I'm measuring the scrollWidth and scrollHeight.

The height doesn't seem to work too well in IE7 and the width seems to just automatically fill up the whole page in both IE and FF3. :)

For more info, check this out:

http://www.faqts.com/knowledge_base/view.phtml/aid/1076
http://www.webmasterworld.com/forum21/5653.htm
http://www.webdeveloper.com/forum/showt ... p?t=171093

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Tue Jul 22, 2008 1:03 pm
Profile WWW
Minor Diety
User avatar

Joined: Fri Apr 11, 2003 5:09 pm
Posts: 4004
Location: Walsall, West Mids, UK
Reply with quote
Post 
Thanks guys :D I'll look more deeply at each solution tomorrow methinks - right now I'm fed up of all this webstuff so I'm taking a break!

Cheers again :D :D :D

_________________
Games to complete:
GTA IV [100%] (For Multiplayer next!)
Fallout 3 [50%]
Rock Band [35%]
http://www.cafepress.com/SmeepProducts


Tue Jul 22, 2008 1:14 pm
Profile WWW
Emperor
User avatar

Joined: Wed Apr 16, 2003 1:25 am
Posts: 2560
Reply with quote
Post 
Satis' solution is doubtlessly bit more expensive for visitor's CPUs and RAM and might not work everywhere but it should be fairly easy to implement.

What I suggest would need more work, especially if you didn't write the source of your blog (in that case you might call it 'mission impossible' at some point), but it guarantees simpler look from outside and will work in any browser it was working in before.

_________________
++


Tue Jul 22, 2008 1:19 pm
Profile WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16701
Location: On a slope
Reply with quote
Post 
haha, funny...Gfree and I posted completely different solutions at the same time.

Personally, I think iframes shouldn't be used... I'd rather pull in the external pages via curl, parse them up in php and then take the chunks you want to keep and insert them into your page. That's basically what gfree was getting at, if I'm not mistaken.

The iframe solution I had is a lot easier and I figured it was more along the lines of what you're looking for. It's not the best solution, though.

Anyway, good luck with that.

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Wed Jul 23, 2008 7:52 am
Profile WWW
Minor Diety
User avatar

Joined: Fri Apr 11, 2003 5:09 pm
Posts: 4004
Location: Walsall, West Mids, UK
Reply with quote
Post 
Yeah, I'm not a fan of iFrames either.

Problem is my brain is frazzled and I think I need to start from scratch on anything webdesign, as it's just not making sense to me :( *starts re-reading*

Well, I get the idea, but I'm finding it a bitch to implement because I have no idea what I'm doing any more ;)

_________________
Games to complete:
GTA IV [100%] (For Multiplayer next!)
Fallout 3 [50%]
Rock Band [35%]
http://www.cafepress.com/SmeepProducts


Thu Jul 24, 2008 12:06 pm
Profile WWW
Felix Rex
User avatar

Joined: Fri Mar 28, 2003 6:01 pm
Posts: 16701
Location: On a slope
Reply with quote
Post 
heh...did you ever? :roll:

I'm available for hire. The weak dollar makes me a bargain. :P

_________________
They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety.


Thu Jul 24, 2008 6:42 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware.