• Dynamic content in php by switching it out with other PHP file

    HeatherKort Member

    Hey guys is there a way to to make your main content block dynamic, by switching it out with other .php files instead of including your header, footer and navigation on each php page? Or is including the header, footer, and nav the prefered way?

    Plus if the content is dynamic will the page address that switches out the content change? If not will that mean if someone directly types or guess your dynamic page (i.e page.php), it’ll load on its own instead of popping up under the same parent page that calls it dynamically?

  • ShikhaTan Member

    PHP was made for this exact purpose; dynamic web pages which can serve content on the fly if partnered with a language such as javascript.

    What you want to do here is detect which page the user is on (via the URI) and then use javascript with ajax to dynamically update the GUI with different pages.

    With including the same content on each page, keep it DRY and use includes to insert content to the page. So you could have a base.php page with:

     
    
Viewing 1 reply thread
  • You must be logged in to reply to this topic.