Results 1 to 8 of 8

Thread: PHP instead of Iframe

  1. #1
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default PHP instead of Iframe

    I'm working on a site with a css layout, but it still has an Iframe in it.
    I would like to get rid of that Iframe.

    I was thinking of changing it to a <DIV> and load the pages thru PHP.

    Is that possible? if yes, how would i do that?

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    iframe is an HTML tag. It's not PHP.

    You might mean to use include() instead (which is php).

    Hope that helps.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. #3
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    81
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I'm just a beginner with php, but know my way around html and css.
    now I would like to get rid of the last frames (iframes) on any site I am making.
    Here is an example of what i am talking about.

    Code:
    <a href="site2.html" target="site">to site2</a>
    
    <iframe src="site.html" name="site" width="585px" id="site" scrolling="no" frameborder="0" allowtransparency="true"></iframe>
    I would like to throw out the Iframe and just use a Div instead, so its easier to maintain the layout of the page.
    The way I'm thinking is that the Iframe is replaced with a Div and that the content of that Div (in this case site.html) is called upon by PHP.
    Also the link (site2.html) would be be inserted into the Div by PHPand replace the first content.

    Can anyone provide me with an example (based on my example) ?

  4. #4
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    You could use AJAX to do just that...

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  5. #5
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by TheJoshMan View Post
    You could use AJAX to do just that...

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    The problem I found with this Ajax script was that after calling my forum index script

    /phpbb/index.php

    it would would consider all phpbb's links as starting from the root folder, instead of the phpbb folder. Basically, all the links to directories would read..

    ./images/forumlogos/filename.jpg

    instead of

    ./phpbb/images/forumlogos/filename.jpg


    ...Hope that makes sense.

    Is there any way to correct this?

    Thanks

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. include() tags the contents of one page and puts it in another.
    <div><?php include('something.htm'); ?></div>
    Is roughly equivalent to <iframe src="something.htm"></iframe>

    2. An iframe is not "part" of the page-- instead it is displaying two pages at once. Everything between the two is separate, including the base paths for links. Any method you use aside from iframes (ajax, php includes, etc) will not work with relative links-- they will be adjusted as they are now PART of the main page (not just embedded as a separate page (iframe) in it).


    If you want to include full pages as they are into other pages, then the best way to do this really is to use an iframe or perhaps full frames (using a frameset page-- slightly more compatible, but also a little harder to code and less control over the size of the frames-- they can't just be a small part of the page, but instead fill up an entire portion of the page-- either top-bottom or left-right).


    Using PHP includes is a great way to include content (specially stored content so that it works smoothly with the rest of your code), but they will be very messy if you are including full pages within full pages. This means that you are doing, effectively:
    <html>.......<html>....</html>...</html>
    And that is completely invalid, not to mention just messy and hard to work with.

    For this reason, full pages should actually be included with frames because that way the head and body sections can both be included normally, so that scripts, css, etc. work in the "included" page.

    If you do use PHP includes or another similar method, then the only part you can effectively include is a portion of the body. Trying to add elements from the head (formatting, scripts, etc), OR trying to change a property (like the base path for links) is nearly impossible, at least without doing a lot more work in the overall conception of the site (and still you would need to specially design the included pages).


    Iframes have their problems, but they are much easier to deal with for this sort of thing than the alternatives, because they are able to keep the content separate from the rest of the page.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #7
    Join Date
    Jan 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    DJR33,

    thanks for the response. That is what I've figured it while browsing the web after I posted my concern.

    The site I'm working on uses the iframe for the phpbb forum only, so I will probably end up sticking to this method until I find an alternative method.

  8. #8
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The only real alternative method is to modify the forum in a major way so that:
    1. All links (and other paths, like for images and scripts) are absolute, that is that they are in the format "http://....yoursite.../file", OR '/directory/file', as both will act independently of the location from which they are called.
    2. There is an alternate template for the forum in which ONLY body elements exist (that is-- the <html> tags and <head> section are entirely removed, as well as the <body> tag itself).

    If both of those work, then in theory, it will be possible to put it in a div.

    However, that requires a lot of work and might still be messy for a few reasons. So I'd say just use the iframe if you want this, or find another way (overall) to design the whole site-- there won't be an easy way to get rid of the iframes otherwise.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •