Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
how to include header.php into another php file
  • I want to include header.php file into another php file.
    i don't want to using php include() function in fuelphp.
    can i using another fuelphp function for including header.php?
  • Harro VertonHarro Verton
    Accepted Answer
    There is never a need to use include() in Fuel.

    I need to know more about what you want to do, where you want to do it, and what this file contains.

    The name "header.php" suggests it has something to do with HTML output, which means it should be a view. And if you are asking how you can construct a page from different views, read the general section on Views in the docs, it has an example. And you can also use the Theme class, which can automate some of it for you, and supports multiple themes.
  • thank you for your answer Mr.Harro Verton

    i want separate header and footer page from template. And then,
    i want to include that separated header and footer file into template like the following.

    <?php include('header.php');?>
       <h1>Hello</h1>
    <?php include('footer.php');?>

    code in header.php
    --------------------------------------
    <html>
    <head>
    <style>
    h1{color:red;}
    </style>
    </head>
    <body>
    -----------------------------------

    code in footer.php
    ---------------------------
    <a> go to top </a>
    </body>
    </html>
    ---------------------------

    Could you help me please?



  • Harro VertonHarro Verton
    Accepted Answer
    All output in FuelPHP is generated through View objects, which in turn use view files, which could be plain php or use a template engine like Smarty or Twig.

    Please read http://fuelphp.com/docs/general/views.html, it explains exactly what views are, and how to use them.

    Under "Nesting views" you find exactly you how can work with a page template, and how to inject header and footer (and other sections) views.

    This is enough if you site (or code) only uses one layout style. If you need to support multiple (this is called theming), you need to read http://fuelphp.com/docs/classes/theme/introduction.html
  • Thank you for your suggestion Mr.Harro Verton


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion