CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2006
    Location
    India
    Posts
    30

    PHP Template Designing

    Hi,
    I am using php for web development.
    I had heard lot about the using php template.
    I heard about the smarty template , making custom template for joomla/ mambo.
    Are they userful.
    I had installed the mambo dreamweaver extension but was not able to know how to use that.

    Can any body provide help, why to use template and how to make custom template.

    Thankyou

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: PHP Template Designing

    If you have a website with many pages, using a template will keep you from having to alter every page each time there is a change to the main design.

    How to do it covers many realms. There is no 1 set way of making a template. In fact there are many ways. Here is a Google search that should be helpful to you.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2004
    Posts
    438

    Re: PHP Template Designing

    If you are competent with php then there are two ways I would suggest for making a template.

    1) The first is to design and make your web template in html as though it were a normal webpage. Save it as template.php for example and then add sections to the html code to add certain elements. For example:

    PHP Code:
        <title>PC Games Website - 
        <?
          echo $pc_title;
        ?>
        
        </title>
    This would set your title element to "PC Games Website - " followed by whatever you set $pc_title to. To use this you would code whatever you want to outside of the html like:

    PHP Code:
    $pc_title="Homepage";
    $main_content="This is a page all about pc games";

    //Then call your template:
    include_once('template.php'); 
    Because the include_once function has the effect of simply adding everything which is in another file to the current one, every variable you set will be available in your template, you can then just print them out wherever you want to as given in the title example.

    2) Secondly would be to build your html template as before, saving it as template.php. When you are happy it all works, save one half as header.php and the other as footer.php. The division should come at either side of the main content area. So your main navigation will most likely be in header.php, any remaiing bits will be in footer. Such as:

    PHP Code:
    //header.php
    <html>
      <head>
        <title>PC Games Website - 
    <?
        echo $pc_title;
    ?>
        </title>
     </head>

      <body>
    Then your main page which includes header and footer:

    PHP Code:
    //index.php
    $pc_title="Homepage";
    include_once(
    'header.php');
      echo 
    "This is a page all about pc games";
    include_once(
    'footer.php'); 
    Then finally your footer
    PHP Code:
      </body>
    </
    html
    Every page you make then works like the index page with different content.
    Hope this helps.

    Daniel

    P.s. I'm sure everyone on this site will come along and criticise this approach but it works for me!
    Last edited by Nibinaear; October 29th, 2006 at 11:51 AM.

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: PHP Template Designing

    Quote Originally Posted by Nibinaear
    P.s. I'm sure everyone on this site will come along and criticise this approach but it works for me!
    Don't be so negative. That is the way I have been doing it for ages.

    Please remember that when editing a post, to put a reason why you edited. Especially when you edit it after posting over 30 minutes prior.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Dec 2004
    Posts
    438

    Re: PHP Template Designing

    Quote Originally Posted by PeejAvery
    Please remember that when editing a post, to put a reason why you edited. Especially when you edit it after posting over 30 minutes prior.
    I normally put an Edit: if I have edited unless it's only minor changes such as spellings and the like. If I have not put a reason it is because I have not made significant changes.

  6. #6
    Join Date
    Oct 2006
    Location
    slavia
    Posts
    42

    Re: PHP Template Designing

    for template-ing ... i usually do the OOP. hope it will worth a bit for u
    ex.
    Code:
    class Page{
    var $banner;
    var $menu;
    var $content;
    var $footer;
    
    function setBanner(){
    
    }
    
    function setFooter(){
    
    }.....
    
    and so on
    
    }
    rgrds,
    szpilman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured