SitePoint Sponsor

User Tag List

Page 3 of 4 FirstFirst 1234 LastLast
Results 51 to 75 of 100
  1. #51
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wrong link

    Here's the correct link: http://www.ultratemplate.com/benchmark/more/

    Also, I /thought/ Smarty was on the list, it's not. You can find a benchmark on the bTemplate site at: http://www.massassi.com/bTemplate/benchmarks/
    The currect version of UltraTemplate isn't used on that site though.

  2. #52
    SitePoint Enthusiast
    Join Date
    May 2001
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smarty benchmarks

    Pretty simplified tests. But, here's the same tests with an accelerator:

    http://www.phpinsider.com/smarty-benchmark/

    Have a look at this page too:

    http://smarty.php.net/whyuse.php

  3. #53
    SitePoint Zealot marcoBR's Avatar
    Join Date
    Jun 2002
    Location
    Brazil
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi!

    I'm seeking for a template-engine that uses XML/XHTML compilant tags in his template files, e.g <myvar value=2 />, <myvar />, <if myvar>HI!</if> or something like this. Do you know anyone???

    Everybody know that Smarty uses template tags like {$myvar} that are assigned for engine recognizes it. Thus, would be possible to modify the Smarty code to accept template tags like <myvar /> once this tag was assigned for engine???

    If yes, what would be the first step to accomplish it???


    Kindest Regards,

    marcoBR

    BTW, sorry 4 my english...

  4. #54
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    I've got no idea who to agree with on this one. On one side there's the template zealots, however, templates IMO are cumbersome, slow, difficult to read and have less control. On the other side is Vincent with his class lay out, problem with this, is it all adds an extra layer to PHP. PHP was designed to be easy!

    Personally, I don't see why this isn't satifictory for templates:

    PHP Code:
    <?php
    include("header.php");
    $query  mysql_query("SELECT name FROM table")
    while( 
    $result mysql_fetch_array($query)) {
    echo 
    $result['name'] . "<br>";
    }
    include (
    "footer.php");
    ?>
    This is how my site runs, and it allows me to have a common layout, while still maintaining SIMPLE and easy to read code, and being faster than all other methods you've got. There is no reason why an extra layer has to be added onto PHP. If, you have the programming skill to add this extra layer, then you should problably implement it in your own programming language, but instead of coding in C, code in assembly so it's nice and fast.

    BTW, why does it matter is PHP shows up in dreamweaver or not (It does)? As, web site designers should not be using a WYSIWYG editors? If they are using WYSIWYG and they are getting paid for it, then personally i think that isn't very professional. Only basic layouts, first designs should be done in WYSIWYG editors, where as things like details, elegant code, and designing with PHP, should be done the old fashion and better (This is a very rant'able topic) way; notepad

    BTW, I'm no where near qualified as some of you, with only 2 years of PHP programming, and some other programming languages.

    -Peter

  5. #55
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by marcoBR
    Hi!

    I'm seeking for a template-engine that uses XML/XHTML compilant tags in his template files, e.g <myvar value=2 />, <myvar />, <if myvar>HI!</if> or something like this. Do you know anyone???
    That would be ASP.NET. I think FastTemplate for PHP does something vaguely similiar, too.
    Mattias Johansson
    Short, Swedish, Web Developer

    Buttons and Dog Tags with your custom design:
    FatStatement.com

  6. #56
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by marcoBR
    I'm seeking for a template-engine that uses XML/XHTML compilant tags in his template files, e.g <myvar value=2 />, <myvar />, <if myvar>HI!</if> or something like this. Do you know anyone???
    Take a look at this thread.

    http://www.sitepointforums.com/showt...threadid=84537

    Matt.

  7. #57
    SitePoint Zealot marcoBR's Avatar
    Join Date
    Jun 2002
    Location
    Brazil
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the link Matt.

  8. #58
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    well I am glad that I stumbled on this thread which has explained everything I needed on templates. I too am pretty new to PHP and any programming in general, I have been asked to look into creating templates for a site. Being that I no the name smarty I thought that I would have a look at what people thought about it... I am so glad that I did.

    Like Peter all my pages started off like his, but I am now having to create multiple pages and functins and well to be honest I am getting myself lost in my code code I know terrible, and needing to re-train how I write the code so that its simpler for me and also for any clients / others that need to use it.

    Vincent, I am afriad that due to my real lack of knowledge on OO etc your example didn't make too much sense, I think I need something more basic (not in this thread guys don't worry) just really asking for soem pointers on where to find basic example, tuts etc (mayeb I will reread the SP ones) and also any decnet book son teh subject.

    Like most people I have Kev book but am finding that it hasn't really taught how I should be laying out my code seperating php and html etc and I am starting to get in a muddle - also errors are occurring which I think is from my code not being written exactly correct.

    Anyway I am enjoying this thread so I do hope it continues, although going back to the beginning, I do have to make one point.

    You mentioned that you design all yoru sites in css only and to change the site you essentially don't touch the html, how? Maybe it because I have to set my sites to work in NS4 and IE4 (client restriction) I find this impossible (although I wish that it was true) just thought that I would ask incase I was missing out on something

    I shall leave the ranting to others but kepe up the good work this thread seems to have helped many people .. hoefully many more

    Sarah
    Regular user

  9. #59
    SitePoint Wizard Mincer's Avatar
    Join Date
    Mar 2001
    Location
    London | UK
    Posts
    1,140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by marcoBR
    Thanks for the link Matt.
    Looking at the times, you hadn't posted in that thread when I replied to this one.

  10. #60
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi All, thought I'd venture back in to my true home of the PHP forums

    I'm with Vincent here, complex template systems like Smart are overkill, if a designer can alter a template with smarty tags in, then they can alter it with basic PHP e.g.
    Code:
    <title><?=$pageTitle?></title>
    and
    Code:
    <title>{pageTitle}</title>
    They are not that different that a designer can't work out that both of them signify the title and move it round to somewhere else in the presentation. If they are going to learn templating syntax they may as well learn some very basic PHP and we are talking very basic here.

    Personally I use XML/XSL for my "templating" along with some output caching as well.

    Why XML + XSLT? - Well the simple answer is that with XML + XSLT I can specify another XSLT file to render with in my config file so I can output to any format. I could detect WAP browsers in my apps init routine and specify to use the XSLT for WML output, or I could allow a user to select a style sheet in their preferences that is more suited to a screen reader or to visually impaired persons - Now let's see you do that with Smarty easily

    It's all a case of getting as near to the basics as possible whilst mainting a balance between usability, maintainability, reliability and efficiency - Something no PHP book I have ever seen teaches you.

    There's a lot more to building software then just writing code, I realised that even more when I started my Software Engineering Degree - Programming and coding are two wholly separate things

    As a side issue, I can't wait for the ZEv2, PHP will finally have mature OO support and efficient OO support too.
    Last edited by Karl; Dec 18, 2002 at 18:25.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  11. #61
    SitePoint Zealot marcoBR's Avatar
    Join Date
    Jun 2002
    Location
    Brazil
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  12. #62
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I will say I agree with vincent also. I am currently working with a couple bigger projects and we are redoing our whole engine to be oop. I sure hope it is more or less up to vincents standards as I really like his work. Anyway I have expanded on the template benchmarks and am in the proccess of adding more.

    This thread is interesting to me as I will be doing the new theme engine for the core. We have made it so that we can plug in any template engine but we were also unsatisfied with the solutions out there. In my quest to know more about it I have collected about 30 or 40 template engines and about 20 different cache systems. Not all of them are benchmarked yet but I'm working on it.

    Anyway after seeing this I think the one I work on will be amazingly allot like what vincent has discussed above. Thanks vincent for the ideas as I have always believed that anybody can make anything but a genious is the one that makes it work the simpelest way possible. Most of us have a tendancy to over complicate things.

    Anyway the benchmarks are in my sig.
    Last edited by webmedic; Dec 20, 2002 at 15:25.
    webmedic.net
    Want your template system benchmarked?
    Template Benches:
    webify_bench

  13. #63
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally I use XML/XSL for my "templating" along with some output caching as well.

    Why XML + XSLT? - Well the simple answer is that with XML + XSLT I can specify another XSLT file to render with in my config file so I can output to any format. I could detect WAP browsers in my apps init routine and specify to use the XSLT for WML output, or I could allow a user to select a style sheet in their preferences that is more suited to a screen reader or to visually impaired persons - Now let's see you do that with Smarty easily
    One thing to consider there may be applying an XSLT "on top of" the finished page, assuming that its XHTML (well formed XML). That is rather than generating XML from the database then applying XSL to generate the desired output, we choose XHTML as the main output format then apply XSL on top of that as needed...

  14. #64
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: An example.

    Originally posted by voostind
    Okay, here goes.

    <snip>

    Vincent
    i am very interested in this and would really like to know/see an example of how you pull it all together to make a page?

    please

  15. #65
    SitePoint Evangelist
    Join Date
    Oct 2001
    Posts
    592
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't what you are asking for already in <snip>?

    If not, could you be a bit more precise maybe?

    Vincent

  16. #66
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I'm almost ready to release a b2 version of my script that emulates ASP.NET. Can you all check it out and give me some critism?

    Demo
    engine source
    test source
    template source

    This may sound a bit taboo, but I'm considering 2 options for the full version: 1. fork php3, 2. make it an extension

    I think if I do the first, it'd be better. What do you all think?

  17. #67
    <? echo "Kick me"; ?> petesmc's Avatar
    Join Date
    Nov 2000
    Location
    Hong Kong
    Posts
    1,508
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both...

    Forking PHP3 means you lose a tiny minority of people, most of which won't use PHP to it's extent otherwise they'd have PHP4.

    Making it as an extension means speed.

    -Peter

  18. #68
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    180
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by voostind
    Isn't what you are asking for already in <snip>?

    If not, could you be a bit more precise maybe?

    Vincent
    <snip> was the classes for the pages

    for example, index.php, i imagine would be something like:

    PHP Code:
    <?php //index.php
    include("application_class.php");
    include(
    "page_class.php");

    $app =& new Application;
    $page =& new Page;

    //do stuff here

    ?>
    i was wondering if you could show us an example of these classes in actually in action

    thanks.

  19. #69
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. Here's what I have so far, and how it works:

    PHP Code:
    <?php
    include("ultratemplate.php"); // I'm going to change it to "odan.php"
    include("datasource.php"); // This is the data abstraction class

    //the code

    $ds = new DataSource();
    $arrResult $ds->read("select user,email from users;",DS_TYPE_MYSQL,array("user"=>"***","password"=>"***","database"=>"mydb"));

    // When reading from a database, the data abstraction class returns the whole result as an array (indexed or hash; hash is default)

    //
    Basically this function loads the template and parses the tags within it.

    page_start("mylayout.php"); // Using a .php file is more secure than a .tpl file, unless you have access to your server

    $rpt1->datasource = &$arrResult;

    page_bind(); // Run all the bind functions for the tags.
    page_display(); // Display the final output.

    That's the basic code to use the builtin repeater. Here's the template:

    Code:
    <html>
      <body>
        <repeater:rpt1>
          <header_template>
            <table border="0">
          </header_template>
          <item_template>
            <tr>
              <td rowspan="2"><img src="/images/users/#user#.jpg" /></td>
              <td>User: #user#</td>
            </tr>
            <tr>
              <td>Email: #email#</td>
            </tr>
          </item_template>
          <alternate_item_template>
            <tr>
              <td rowspan="2"><img src="/images/users/#user#.jpg" /></td>
              <td>User: #user#</td>
            </tr>
            <tr>
              <td>Email: #email#</td>
            </tr>
          </alternate_item_template>
        <footer_template>
          </table>
        </footer_template>
      </repeater:rpt1>
     </body>
    </html>

    That's it. The "#...#" delimiters tell the repeater where to insert the data for each column. Also, It may take a little more html than some of the other solutions, but I think it looks better.

    See my previous post for the location of a running demo. I haven't benchmarked it yet. I hope it's not awfully slow, It shouldn't be though.

  20. #70
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    the case of phpBB templates

    The first template engine I worked with was the phplib engine used in phpBB templates. At first, like many, I thought it was amazing. I could edit these template pages and voila, the result would show up on my forums and I never had to mess with the php code.

    Now that I have "matured" a bit in my understanding of templates (thanks mostly to Vincent) I realized a very, very critical point. Templating is NOT an engine, it is an idea. Pulling the presentation layer away from the code so that you don't have to modify the source code to get a different look can be done using PHP+CSS because it is not an engine, but simply a way of dividing up the tasks.

    This actually became apparent to me earlier while making a "MOD" on my board. I realized that if you want to change the presentation of the forum, it is actually necessary to modify both the code and the templates. It is the case that the templates can actually get "outdated" as the code refactors. To me, this is not right.

    The templates should be "logic-free" widgets. You should probably have one main template that does the primary painting on the page (header, footer and sidebars) and then for each widget you add, it should populate and insert the contents of its result. For instance, if my application had a list page, where I showed a paginated list of items, the "list" template should be used. That way, if I later added a new "box" on one of my pages that showed a list, I would not have to change the widget template (unless of course the template was bad to begin with). Look at this forum and try to put your finger on the different widgets it uses, and make a template for each of them. Many of these templates will be very small, and you simply include them when the data is ready and buffer the result to be used in the main template.

    This follows what Vincent pounds in our heads of code reuse. If you think about it, phpBB templates repeat html code all over the place. They have a template for posting, template for viewing forum list, template for viewing message list, template for searching, template for search result list. That is TONS of repeated presentation layer code. If they had narrowed it down to widget templates (whether the tempates are PHP or some language it doesn't really make a difference) they could have reduced the amount of work the template artist had to do.

    So whether you choose to use PHP (like me) or you choose to use "insert favorite template engine of choice," you should think of your templates as widgets instead of as page-specific templates, with one or two "main" templates that wrap the entire page in a basic layout. And the nice thing about this method is that you will see your widget "refactor" themselves as new situations present themselves, but never will you have to modify 20+ templates to make a new style. Try to consider "merging" similar widgets together that only differ by class definitions and come up with standard class names just like Qt or GTK. For instance, if you use a sideblock, but some are red and some need to be green, instead of making several templates for almost the same code, try to make the classname dynamic on the block or something like that.

    By the way, if you are interested in a template engine that is just php with alternative wrapper tags, check out HTML_Template_Xipe in PEAR. All it does is let you change the tags used for php, eliminates the need for brackets by using indentation and does courtesy "echo" statements when a simple variable is enclosed in the tags. It is simply a layer between the designer and the cached version which allows you to type less and get a php result page. In the end I will just type the php thanks and skip the processing, but since they can be cached outside of the program being run, you can just create the template when the designer hands it to you and drop it in place (maybe use a commandline script).

  21. #71
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with the fact that 3rd party template parsers are mostly useless with the fact that they have a ton of features which could **Possibly** be useful for **some** project that **someone** out there **might** want to do.

    A template system needs to be more specific than that. My template system does exactly that. The logic it supports are if/else tags, as well as including other templates directly within a template, using an <include> tag. It also does allow use of PHP code within the template, if it is enabled, and if it doesn't need to be used it is disabled, Also, templates are only parsed once, and page execution for a full forum thread is about 0.18 seconds, (with all features enabled).

    This is hardly overkill in my opinion, and does allow the average user to make changes easier, with XHTML-style tags.

    One thing I really hate about Smarty is it's dumb syntax, especially If statements, in mine it is direct PHP syntax:

    Code:
    <if $hello==1><include template="header" /></if>
    versus a similar PHP Code:

    PHP Code:
    <?php if ($hello==1)
    {
       
    $template->include('header');
    }
    ?>
    and then there's the dumb smarty method:

    Code:
    {if %Hello% eq 1}something weird...{/if}
    I don't think templates are right for everybody, but I think it is useful in some cases. It's like everything, sometimes things are right for a situation, sometimes not, that's the way it goes.

    <end my opinion>
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  22. #72
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are making an unfair comparison here.

    Smarty can do if statements that look like this, without the % and 'eq':

    PHP Code:
    {if $hello == 1}{include file="header"}{/if} 
    I don't see how this is anymore "dumb syntax" then your
    PHP Code:
    <if $hello==1><include template="header" /></if> 
    If all your template does is simple if / else statements and perhaps loops, you might as well use PHP syntax for it.

    I don't think templates are right for everybody, but I think it is useful in some cases. It's like everything, sometimes things are right for a situation, sometimes not, that's the way it goes.
    IMO, templates are always useful as soons as your script goes anything beyond "Hellow World"-complexity. It's just that template engines aren't always needed. Unfortunately a lot of people mix these two terms in their posts, while they are totally different concepts.

  23. #73
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually it doesn't do loops either, and I didn't know Smarty could use that sort of if syntax, i take back my previous statement, but I still think it has way too many features to make it a useful solution.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  24. #74
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    after rethinking some things... it appears my point on smarty having too many features is strengthened.

    Why support the other syntax? It just makes it slower.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  25. #75
    SitePoint Enthusiast wogboy's Avatar
    Join Date
    Jun 2002
    Location
    Melbourne
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It might make the initial compilation of the template slower as the regexp needs to be more complicated to support it, but from there on you are just executing native PHP until the template changes again. Smarty will only ever parse your template once if the template never changes.
    Last edited by wogboy; Feb 18, 2003 at 18:59.


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
  •