20i Reseller Hosting

PHP Template Design Pattern Help

Discussion in 'Scripts and Coding' started by accelerator, Aug 24, 2015.

Thread Status:
Not open for further replies.
  1. accelerator United Kingdom

    accelerator Well-Known Member

    Joined:
    Apr 2005
    Posts:
    7,461
    Likes Received:
    114
    Hi Guys

    If I want to create easily reusable PHP template components, is it best to use a PHP object for each component? Can anyone link to a good tutorial on this?

    Also, if I want to have a single PHP component that I can easily use across multiple sites, how can this be done?

    Thanks :cool:
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
    articles.co.uk
     
  3. AssetDomains

    AssetDomains Well-Known Member

    Joined:
    Feb 2010
    Posts:
    3,046
    Likes Received:
    69
    If your a complete beginner maybe start with something like

    http://www.w3schools.com/php/

    Tuts plus has some decent tutorials on php but you have to pay

    A lot of great stuff is on YouTube as well

    Are you just looking to include page elements like menus, sidebars footers etc

    http://www.w3schools.com/php/php_includes.asp in a cpanel environment you can include files in multiple addon sites with the correct file path.

    If your looking to build something serious in php, sites with user login database driven content follow a decent primer tutorial on php then jump in with a framework.
    I highly recommend Laravel and this site has some amazing guides it looks complex at first but will save tons of time in the long run.
    https://laracasts.com/series/laravel-5-fundamentals
     
  4. accelerator United Kingdom

    accelerator Well-Known Member

    Joined:
    Apr 2005
    Posts:
    7,461
    Likes Received:
    114
    Thanks. I'm not a complete beginner, I know how to do the standard PHP include. However, at the moment, I only know how to do this on a single site.

    What I'm specifically looking at is ways to create a component based system that can easily be updated over multiple sites, e.g. all sites have a shared footer, and you only have to amend it once then all sites use the update.

    Thanks
     
  5. AssetDomains

    AssetDomains Well-Known Member

    Joined:
    Feb 2010
    Posts:
    3,046
    Likes Received:
    69
    If the sites are going to be on the same cpanel then your standard include will work just enter the full path to the file

    Code:
    [COLOR=#007700][COLOR=#007700][COLOR=#007700]include [/COLOR][COLOR=#dd0000]'/home/somefolder/someotherfolder/footer.php'[/COLOR][COLOR=#007700];[/COLOR]
    [/COLOR][/COLOR]


    Alternatives would be to store you code in a database accessable by all the sites
     
  6. accelerator United Kingdom

    accelerator Well-Known Member

    Joined:
    Apr 2005
    Posts:
    7,461
    Likes Received:
    114
Thread Status:
Not open for further replies.