SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to call external page and how to place into specific location ?

    Hello Friends,
    I have designed a page, it has header, footer, menus, left panel, right panel and body. Here I kept all in separate file and included with PHP include() function. And I need when I click any menu (I used hyperlink) the specific page should be open in the main body location. So my problem is how to call specific page by specific menu and how to place in main body page at specific location. In this case my main body page, menu page and external page all are different page. If anyone have good idea about this kindly help me.

    Thanks & Regards,
    Premashish

  2. #2
    SitePoint Evangelist
    Join Date
    Apr 2009
    Location
    South Carolina
    Posts
    458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way would be to have the menu for the body of your page set a variable. Then in your code have the the variable part of your include.

    If the menu points to page1, set a variable $page01. Where page01 is the name of a file you want in the body section. Then use include to include that file.

    I may be wrong, but I think for the link to work, you would need to use something like an iframe in the body of your page.
    Each day is a learning experience.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Posts
    67
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Nein! no iframes plz.

    Something like this should work:
    PHP Code:
    <html>
    <head>
    <title>blabla</title>
    </head>
    <body>
    <div id="menu">
    <ul>
    <li><a href="">Home</a></li>
    <li><a href="?page=contact">Contact</a></li>
    <li><a href="?page=about">About us</a></li>
    <ul>
    </div>
    <div id="body">
    <?php
    $page 
    "home";
    if(isset(
    $_GET['page']) && strlen($_GET['page']) > 0){
        
    $page $_GET['page'];
    }
    include(
    'path_to_your_page_files/' $page '.php');
    ?>
    </div>
    </body>
    </html>


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
  •