Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Coding help please - Iframe in Postnuke
  • Posted: 10.01.2007, 04:59
     
    manarak
    rank:
    Helper Helper
    registered:
     December 1969
    Status:
    offline
    last visit:
    18.07.08
    Posts:
    393
    Hello

    I need some help with the following please.

    Suppose I have file1.php in the PN main directory.
    file1.php contains the basics of the PN framework, in this manner:

    Quote



    include 'includes/pnAPI.php';
    pnInit();
    include 'includes/legacy.php';

    if(!IsSet($mainfile)) { include ("mainfile.php"); }
    include("config.php");

    include("header.php");
    OpenTable();

    *** my stuff here ***

    CloseTable();
    include("footer.php");


    In file1.php, I can use PN functions such as pnSecAuthAction, pnUserVars, etc...

    Now I have also file2.php, located in the same PN root dir as file1.php.
    I want to call file2.php from file1.php using an Iframe:

    Quote


    include 'includes/pnAPI.php';
    pnInit();
    include 'includes/legacy.php';

    if(!IsSet($mainfile)) { include ("mainfile.php"); }
    include("config.php");

    include("header.php");
    OpenTable();



    CloseTable();
    include("footer.php");


    In file2.php I also need the functions of the PN framework, but file2 does not recognize the logged in user, regardless if I include in file2 the PN includes or not.
    I suppose this is normal behavior for Iframes, but is there a way around it, and have my user properly identified by file2.php as being logged in?
    I think, since both files are on my site, the PN cookie should be readable also by file2?
    If so, why isn't the user logged in inside the iframe, if he is logged in in the parent frame?

    Is there a way to get the user to be logged in inside the iframe?
    I have to use an Iframe for what I want to achieve.

    I would appreciate any help.


    P.S.
    Posting full code snippets to the forum, including the PHP tags, somehow does not work
  • Posted: 10.01.2007, 11:34
     
    personofinterest
    rank:
    Softmore Softmore
    registered:
     April 2006
    Status:
    offline
    last visit:
    17.01.07
    Posts:
    73
    Is this happening with IE only? Although it specifically references ASPX pages, I think the following may be a similar issue. It's possible that a different session cookie is being generated for the main page and the iframe. http://www.aspnetresources.com/blog/frames_webforms_and_rejected_cookies.aspx
  • Posted: 10.01.2007, 13:02
     
    manarak
    rank:
    Helper Helper
    registered:
     December 1969
    Status:
    offline
    last visit:
    18.07.08
    Posts:
    393
    Of course, the solution should work also in other browsers, but I was stopped by this problem while testing with IE.
    And since IE is a must (80% of my users), I need to solve that problem.

    I thought that PN already uses a P3P policy for the cookies?
  • Posted: 10.01.2007, 16:12
     
    ZarToXidE
    rank:
    Helper Helper
    registered:
     January 2005
    Status:
    offline
    last visit:
    09.02.08
    Posts:
    455
    An iframe is to display a page, not using a system, sort of. As you can display a page from site X, in an iframe in site Y. Ofcourse the page on site X, doesn't know if the user on site Y is logged in or not.
    .
    For file1.php you load the PostNuke system, and in file2.php you don't. Since an iframe is for use of external pages, this is normal if you don't load the system within that file.
    .
    Just load PostNuke within file2.php, only include the API, start it using the pnInit(), and you can use PostNuke within the iframe. The use of an iframe doesn't update the browser address, since it's in a frame. Searh engines will find the content of file2.php and index those, resulting in visitors from search engines directly hit the file2.php, and not file1.php. Which means they won't see the content around the iframe for that matter.
    .
    BTW: the starting of PostNuke you quoted, is way old. Can be shortend to:

    Code

    <?php

    include("includes/pnAPI.php");
    pnInit();
    include("header.php");
    OpenTable();

    .. your stuff ..

    CloseTable();
    include("footer.php");

    ?>

    The open and close table stuff isn't actually needed either.

    --
    Doe Maar Freak
  • Posted: 10.01.2007, 23:16
     
    manarak
    rank:
    Helper Helper
    registered:
     December 1969
    Status:
    offline
    last visit:
    18.07.08
    Posts:
    393
    Zar, the problem is about IE not behaving as specified by standards.
    Nowhere it is said in HTML specs that iframe should only open frames to other sites, and that opening frames to another HTML file situated on the same domain domain or server is not supported.

    What I want to do works in firefox, but not IE, probably because of this P3P stuff nobody needs.

    MS also modified IE default behavior to not accept http://username:password@site.com anymore, which is a stupid thing in my opinion.
    Another violation of standards.

    Thank you for pointing out the obsolete stuff in the includes, I will get rid of that dead weight.



    edited by: manarak, Jan 10, 2007 - 06:19 AM
  • Posted: 11.01.2007, 04:12
     
    manarak
    rank:
    Helper Helper
    registered:
     December 1969
    Status:
    offline
    last visit:
    18.07.08
    Posts:
    393
    Problem Solved:

    Personofinterest was right and IE accepts to work as expected when a P3P privacy policy is used.
    Thank god, a compact policy is enough.

    In index.php (in PN root directory) I inserted

    Quote

    header("P3P: policyref=\"http://www.mysite.com/w3c/p3p.xml\", CP=\"DSP IDC CUR ADM DELi STP NAV COM UNI INT PHY DEM\"");

    just before

    Quote

    include 'includes/pnAPI.php';


    and now it works like a charm in both IE and FF.

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula