Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding the admin bar to a php file.

  • Avatar of maburker
    maburker
    Participant

    @maburker

    Hello,

    How do you add the admin bar to a custom php file for the home page. I have tried adding action function and nothing seems to get it to work. There are no widgets on this page just some html wrapped in php. Any help is appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Xevo
    Xevo
    Participant

    @xevo

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    So you’re saying you want to use the BuddyBar outside of WordPress?

    If so, this article helped me:

    http://dev.commons.gc.cuny.edu/2009/10/12/displaying-the-buddypress-admin-bar-in-other-applications/

    I used this on a Moodle install and it worked.

    Is your homepage powered by WordPress? If so, the answer will be much easier.

    Let us know what your setup is.

    Avatar of maburker
    maburker
    Participant

    @maburker

    No, the costume home page just replaced the regular home page in the buddy press theme. The page isn’t out side of buddy press. We tried to have a home page on a sub domain but, we couldn’t figure out how to direct the members successfully.

    Avatar of maburker
    maburker
    Participant

    @maburker

    Ok, we moved it out of wordpress onto a sub domain(e.g. home.mysite.com). This seems to work for right now. Some other coding is required. We just need to figure out how to add the admin bar. The page is a php page with all the html in that file and some php functions. So, there isn’t a header file or a footer file. The article for adding the bar to external applications won’t work for this. At least I can’t get it to work. Thanks for any help.

    Avatar of NoahY
    NoahY
    Member

    @noahy

    In case anyone googles here, the article posted by r-a-y works for different subdomains, but needs a bit of tweaking, based on this post:

    http://roneiv.wordpress.com/2008/01/18/get-the-content-of-an-iframe-in-javascript-crossbrowser-solution-for-both-ie-and-firefox/

    Basically, we need to put the wordpress page with the adminbar only in an invisible iFrame and access its content from the parent.

    To do this, first we add the iFrame to the external php / html file. Something like this works:

    `

    `

    Next, we need to edit the `page-component.php` file, adding a head and body onload element:

    `

    document.domain = “site.com”

    `

    This sets document.domain to the same domain as we will specify in our external file. It also adds jQuery (needed for buddypress-ajax-chat on my site). Finally, it sets an onload event to tell the parent window to grab it’s content.

    Next, we have to add some more javascript to the parent, along with the other links mentioned in the article above:

    `document.domain=”sirimangalo.org”;
    function getNav() {
    var content = document.getElementById(‘bpsrc’).contentWindow.document.body.innerHTML;
    document.getElementById(‘bpContainer’).innerHTML = content;
    }`

    This sets the domain again, allowing the function to pass from the iFrame on up, and provides the function to grab the content of the source frame and output it to the “bpContainer” div.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.