SitePoint Sponsor

User Tag List

Page 3 of 3 FirstFirst 123
Results 51 to 58 of 58
  1. #51
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post a link ? Cannot find the post myself now But what I can do is upload the PDF for you here

    Enjoy.
    Attached Files Attached Files

  2. #52
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #53
    SitePoint Member Spiff Dog's Avatar
    Join Date
    Jun 2002
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    The best? Maybe for PHP. :)

    Quote Originally Posted by turboweb
    All i have to say is "Typo3"

    The absolute best CMS, template and integration system around
    I actually built one for ASP.NET that used compiled template assmeblies, a smart class factory and a FileWatcher object on a directory. To use the new template, just drop the template assembly into the Templates directory. The FileWatcher would detect that a new assembly was available and the Smart Class factory would update it's ArrayList to contain a reference to the new template. *allahkazam!*, you got a new template available.

    Since all the page logic in ASP.NET is written in code-behind files, you don't have to tangle with spagetti code. Just inherit the master template class, utilize the standard webcontrol objects from your template class and it will return the right template-based look and feel based on user-settings.

    Anyway, just thought I'd throw my experience into the hat.

    Spiff
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    "Home is where you hang your @."
    Spiff Dog Design

  4. #54
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, this part actually looks interesting though

    The FileWatcher would detect that a new assembly was available and the Smart Class factory would update it's ArrayList to contain a reference to the new template.
    I'm wondering, has anyone managed to do something like this in PHP as I can't think of seeing something like this in these forums.

    Mind you, my memory isn't what it was once

  5. #55
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,627
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I have something vaguely similar brewing, though it does not have a read from file ability at this time.

    Basically, I have generic HTML objects with some databinding capabilities that one can use to programmatically create pages. I have yet to put in an overall read from file and assemble page functionality, nor have much in the way of plans to do so as I dont need that.

    WWB

  6. #56
    SitePoint Member
    Join Date
    Apr 2004
    Location
    Mexico City
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb MVC, template engines - Example #1

    Hi, I've worked with Brian Lozier's php-based template "engine"
    ( http://www.sitepoint.com/article/bey...plate-engine/1 )
    . After having studied some bit of the MVC model, and the Apache Velocity project, and another article found elsewhere (style-free stylesheets with xslt), I came out with a very interesting methodology for php-based websites, and it's worked great. Modules are built so easily that I get bored at the job :P

    Anyway, here's an example of my approach:

    <?php
    // yourfile.php
    require_once('prepend.php'); // this line *could* be ignored:
    // *wink wink, nudge nudge*

    require_once('includes.php');
    require_once('my_model_file_for_this_particular_module.php');
    checkprivilegesandsecurityyaddayadda('privilegename');

    function handle_request()
    { // this function is gonna be called by the framework/engine/etc called
    // by your prepend.php.

    // ******* 1.- Get basic data *******

    $db=new readonly_databaseobjectwhatever('subclass');
    // based on phplib's db_sql - for most database operations.
    $dbw=new readwrite_databaseobject('subclass');

    $pagetitle=$visibletitle='Guess what goes in here';
    // $pagetitle is for the 'title' tag. $visibletitle is for the 'h1' tag.

    $params=array('var1'=>$something,'var2'=>$somethingelse);

    // ******* 2.- Choose template *******
    switch($_GET['action'])
    {
    case 'update':$bodyfile='updater.tpl';
    default:$bodyfile='default.tpl';
    }

    $body = new Template(TPL_DIR . 'reports/' . $bodyfile);
    // Here goes your customized version of Brian's template engine

    // ******* 3.- Database action(s) ********

    $params['resultdata']=nifty_db_function($db,$someparameters,$_GET,$whatever,true);

    nifty_log_function_to_keep_track_of_your_actions($yaddayadda);

    dispose_database_object($dbw);
    dispose_database_object($db);

    // ******* 4.- Return template parameters *******

    $body->set_vars($params);

    return array('maintemplate'=>TPL_DIR . 'main/defaultmain.tpl',
    'mainparams'=>array(
    'body'=>$body,
    'title'=>$pagetitle,
    'title2'=>$visibletitle,
    'linkedscripts'=>$linked_javascript_list,
    'linkedstylesheets'=>$linked_stylesheet_list,
    'metatags'=>$metatag_list,
    ),
    'customheaders'=>$custom_http_header_list,
    );
    }
    ?>

    The file "engine.php" uses TWO template objects: One for the defaultmain.tpl (whose parameters are 'mainparams'), and another, which is the $body template.

    Notice that in the main file i don't use a single echo statement.

    So, to shift the debate to something more useful than "to php or not to php?", how about sharing your particular multitier methodology in this thread?

  7. #57
    SitePoint Zealot
    Join Date
    Jun 2003
    Location
    Middle / East TN
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the creation of my own template engine, I addressed this issue differently.

    index.tpl
    Code:
    {TEXT}
    <ul>
         {LIST_ITEMS}
    </ul>
    PHP Code:
    Code:
    $tpl =& new Template('index.tpl');
    
    $tpl->startLoop('LIST_ITEMS','loop_item.tpl');
          while ($result =& $db->getRow()) {
                $tpl->runLoop();
                $tpl->add('TITLE',$result['title']);
           }
    $tpl->endLoop();
    
    $tpl->display();
    loop_item.tpl
    Code:
    <li>{TITLE}</li>
    I think it keeps things separated better and you don't have the template scripting mixed up with your html.
    There are 10 kinds of people in this world,
    those who can read binary and those who can't.

  8. #58
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pretty much how I've done that just now. Though I don't actually use any Template script, I use PHPs

    PHP Code:
    ereg_replace$tag$string$content ); 
    Which removes the bloat of having to use any Template system at all PHP by default is the Template system, but that's just being picky I suppose

    As to Rick_g22's posting, I do not follow it. There is far too much ambiguinity (did I spell that correctly ? ) in it, too much interpretation can be seen from it to get anything specific from it

    Not sure either, where the MVC pattern fits into it


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
  •