to template or not

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrea A

    to template or not

    Hi,
    i'm developing a website that will have an huge amount of visitors a day -->
    it will be a contest with 100.000$ of prize.
    I'm concerning about using a template class (and which one do you suggest)
    or developing an optimized set of pages without using class nor PEAR
    package.

    What do you think about?
    What will be your action if you'll be me?


    Thanks in advance,
    A.


  • Niels Berkers

    #2
    Re: to template or not

    Hi Andrea,
    i'd suggest you go for it! use those templates.
    I'm working for a broadcasting company, we are serving upto 6.000.000 pages
    per month without big performance problems
    We are using the template class of phplib, which is great.

    Cheers

    Niels

    "Andrea A" <nospam@nospam. com> wrote in message
    news:c17ndg$l3t $1@newsreader.m ailgate.org...[color=blue]
    > Hi,
    > i'm developing a website that will have an huge amount of visitors a[/color]
    day -->[color=blue]
    > it will be a contest with 100.000$ of prize.
    > I'm concerning about using a template class (and which one do you suggest)
    > or developing an optimized set of pages without using class nor PEAR
    > package.
    >
    > What do you think about?
    > What will be your action if you'll be me?
    >
    >
    > Thanks in advance,
    > A.
    >
    >[/color]


    Comment

    • Andrea A

      #3
      Re: to template or not

      thanks for your answer.
      Can you also tell me the hardware you use for serving this amount of pages?

      thanks a lot,
      a.
      [color=blue]
      > Hi Andrea,
      > i'd suggest you go for it! use those templates.
      > I'm working for a broadcasting company, we are serving upto 6.000.000[/color]
      pages[color=blue]
      > per month without big performance problems
      > We are using the template class of phplib, which is great.
      >[/color]


      Comment

      • dr. zoidberg

        #4
        Re: to template or not

        Andrea A wrote:[color=blue]
        > Hi,
        > i'm developing a website that will have an huge amount of visitors a day -->
        > it will be a contest with 100.000$ of prize.
        > I'm concerning about using a template class (and which one do you suggest)
        > or developing an optimized set of pages without using class nor PEAR
        > package.
        >
        > What do you think about?
        > What will be your action if you'll be me?[/color]

        You can and should use Smarty. Smarty can create html cache of every
        page and server it like it is HTML. That way you wouldn't overload your
        server.


        Comment

        • Niels Berkers

          #5
          Re: to template or not

          pIV dual 2,4Ghz 1Gig Mem frontend
          pIII dual 1,3Ghz 800Gig Mem backend

          Cheers

          Niels
          "Andrea A" <nospam@nospam. com> wrote in message
          news:c18hjj$lvo $1@newsreader.m ailgate.org...[color=blue]
          > thanks for your answer.
          > Can you also tell me the hardware you use for serving this amount of[/color]
          pages?[color=blue]
          >
          > thanks a lot,
          > a.
          >[color=green]
          > > Hi Andrea,
          > > i'd suggest you go for it! use those templates.
          > > I'm working for a broadcasting company, we are serving upto 6.000.000[/color]
          > pages[color=green]
          > > per month without big performance problems
          > > We are using the template class of phplib, which is great.
          > >[/color]
          >
          >[/color]


          Comment

          • rush

            #6
            Re: to template or not

            "Andrea A" <nospam@nospam. com> wrote in message
            news:c17ndg$l3t $1@newsreader.m ailgate.org...[color=blue]
            > Hi,
            > i'm developing a website that will have an huge amount of visitors a[/color]
            day -->[color=blue]
            > it will be a contest with 100.000$ of prize.
            > I'm concerning about using a template class (and which one do you suggest)
            > or developing an optimized set of pages without using class nor PEAR
            > package.
            >
            > What do you think about?
            > What will be your action if you'll be me?[/color]

            I would obviously go with templates. Usually performace probelms are
            somewhere else (like db), but I would suggest that you take in consideration
            some of the template systems which have support for cacheing.

            rush
            --



            Comment

            • R. Rajesh Jeba Anbiah

              #7
              Re: to template or not

              "Andrea A" <nospam@nospam. com> wrote in message news:<c17ndg$l3 t$1@newsreader. mailgate.org>.. .[color=blue]
              > Hi,
              > i'm developing a website that will have an huge amount of visitors a day -->
              > it will be a contest with 100.000$ of prize.
              > I'm concerning about using a template class (and which one do you suggest)
              > or developing an optimized set of pages without using class nor PEAR
              > package.
              >
              > What do you think about?
              > What will be your action if you'll be me?[/color]

              In reality, templating is good; but not all template engines. In
              the company I'm working for, we're trying to set our own lightweight
              framework. We're researching for past few weeks on template systems.
              In short, you cannot simply separate code and logic---if you can
              separate it, you can simply do it in PHP itself ('cos PHP itself is a
              template engine; many people forget that often). Unfortuantely many
              people believe that the template markup like {SOME_VARIABLE} is not a
              _code_---infact they're; there is indeed no difference between {foo}
              and <?=$foo?>.

              These links may be helpful to further dig on the subject:

              1. http://www.phpbuilder.com/annotate/m...hp3?id=1013434
              2. http://www.phpbuilder.com/annotate/m...hp3?id=1013711
              3. http://www.phpbuilder.com/annotate/m...hp3?id=1013461
              4. http://www.phppatterns.com/index.php...cleview/4/1/1/
              5. http://www.massassi.com/php/articles/template_engines/
              6. http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf

              --
              "Success is not what you achieve, but it is what you die for"
              If you live in USA, please support John Edwards.
              Email: rrjanbiah-at-Y!com

              Comment

              • rush

                #8
                Re: to template or not

                "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                news:abc4d8b8.0 402222115.15ed7 d36@posting.goo gle.com...[color=blue]
                > "Andrea A" <nospam@nospam. com> wrote in message[/color]
                news:<c17ndg$l3 t$1@newsreader. mailgate.org>.. .[color=blue]
                > In reality, templating is good; but not all template engines. In
                > the company I'm working for, we're trying to set our own lightweight
                > framework. We're researching for past few weeks on template systems.
                > In short, you cannot simply separate code and logic---if you can
                > separate it, you can simply do it in PHP itself ('cos PHP itself is a
                > template engine; many people forget that often). Unfortuantely many
                > people believe that the template markup like {SOME_VARIABLE} is not a
                > _code_---infact they're; there is indeed no difference between {foo}
                > and <?=$foo?>.[/color]

                Well, yes, in extremely extended definition you can say that both are code,
                in the same way you can also say that html is code. Heck you can even say
                that this message is code since it is coded in ASCII. What people reffer to
                is the separation of programming code from the markup. One type of languages
                is called markup languages, and another is called programming languages, and
                for reason. The difference is that html and {SOMEVAR} is markup code wich
                defines static properties, while <? php code is used to model dymanic
                propertiers using if's loops, etc. And those two can be seprated, and should
                imho.

                There are very simple tests to see if template system separates programming
                code from the html well. If you can not change behaviour of your app without
                editing the files that contain html, than they are not sparated well. If you
                can not change the some parts of html template without editing the file that
                contains programming constructs like if's, loops etc, they are not separated
                well.

                rush
                --



                Comment

                • Kevin Thorpe

                  #9
                  Re: to template or not

                  Andrea A wrote:
                  [color=blue]
                  > Hi,
                  > i'm developing a website that will have an huge amount of visitors a day -->
                  > it will be a contest with 100.000$ of prize.
                  > I'm concerning about using a template class (and which one do you suggest)
                  > or developing an optimized set of pages without using class nor PEAR
                  > package.[/color]

                  Personally I avoid template libraries and rely on php itself. You can
                  reduce your actual pages to templates by following this process:

                  Write function or class libraries to encapsulate your business logic.
                  These should be placed outside the document root for security (if php
                  gets turned off no-one can download the source).

                  Put most of your control logic at the top of your webpage.

                  Use as little php inside <html></html> as possible. Simple variable
                  inserts and loops are fine. This way you don't need to learn another
                  language (the templating language) and can rely on php.

                  The only time this falls apart is when you need language translations.
                  We do this quite happily though. If the php code in the page is simple
                  enough you can get pages translated entire and use mod_rewrite or
                  Apache's own language handling to servie the right ones.

                  NOTE: we have some bits of our site written on Smarty and I have to
                  scratch my head a lot when I try and modify them. Also sometimes I want
                  to do things that Smarty just can't handle. I'm much happier in pure php.

                  ....... so anyway so on to the religious flamewar

                  Comment

                  • R. Rajesh Jeba Anbiah

                    #10
                    Re: to template or not

                    "rush" <pipa@rush.aval on.hr> wrote in message news:<c1cdc7$al 2$1@ls219.htnet .hr>...[color=blue]
                    > "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                    > news:abc4d8b8.0 402222115.15ed7 d36@posting.goo gle.com...[color=green]
                    > > "Andrea A" <nospam@nospam. com> wrote in message[/color]
                    > news:<c17ndg$l3 t$1@newsreader. mailgate.org>.. .[color=green]
                    > > In reality, templating is good; but not all template engines. In
                    > > the company I'm working for, we're trying to set our own lightweight
                    > > framework. We're researching for past few weeks on template systems.
                    > > In short, you cannot simply separate code and logic---if you can
                    > > separate it, you can simply do it in PHP itself ('cos PHP itself is a
                    > > template engine; many people forget that often). Unfortuantely many
                    > > people believe that the template markup like {SOME_VARIABLE} is not a
                    > > _code_---infact they're; there is indeed no difference between {foo}
                    > > and <?=$foo?>.[/color]
                    >
                    > Well, yes, in extremely extended definition you can say that both are code,
                    > in the same way you can also say that html is code. Heck you can even say
                    > that this message is code since it is coded in ASCII.[/color]

                    Well, it sounds that you didn't try to understand what I said or
                    you didn't read the link that I provided.
                    [color=blue]
                    > What people reffer to
                    > is the separation of programming code from the markup.[/color]

                    So...is that your defintion too? Some template engines claim
                    separation of dynamic code from static code---for which they just use
                    another markup (instead of <?=$foo?>) like {foo} or [foo] or
                    <!--foo--> etc. In all cases, it is merely a *substitution* of PHP's
                    template system with another one. Some template engines like Smarty
                    claims separation of business logic from presentation logic---not
                    separation of code; if you have tried Smarty you might be knowing
                    that.

                    All template engines use pull or push logic. So, the intution is
                    why not use PHP which is also a template system? It seems you claim
                    using <?=$foo?> in PHP developed web application is bad; but if we use
                    {foo} it is ok. So, it sounds that we may use ASP code as a markup in
                    PHP and vice-versa---and this argument is completely silly, IMHO.

                    [color=blue]
                    > One type of languages
                    > is called markup languages, and another is called programming languages, and
                    > for reason. The difference is that html and {SOMEVAR} is markup code wich
                    > defines static properties, while <? php code is used to model dymanic
                    > propertiers using if's loops, etc. And those two can be seprated, and should
                    > imho.[/color]

                    It sounds that you haven't gone through Harry's
                    AwesomeTemplate Engine.
                    [color=blue]
                    > There are very simple tests to see if template system separates programming
                    > code from the html well. If you can not change behaviour of your app without
                    > editing the files that contain html, than they are not sparated well. If you
                    > can not change the some parts of html template without editing the file that
                    > contains programming constructs like if's, loops etc, they are not separated
                    > well.[/color]

                    PHP itself is a template engine. Templating can be done with
                    anything--even with PHP, which is fast & easy than other weird
                    template markups.

                    --
                    /\
                    / \\ <http://www.homeless-international.o rg>
                    / [] \\\ Email: rrjanbiah-at-Y!com

                    Comment

                    • rush

                      #11
                      Re: to template or not

                      "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                      news:abc4d8b8.0 402232121.ef1af 84@posting.goog le.com...[color=blue]
                      > Well, it sounds that you didn't try to understand what I said or
                      > you didn't read the link that I provided.[/color]

                      I have read those links, and tried to understand your point. Please let me
                      assure you that I can understand that other people have different opinions
                      and preferences, but in the same way I like to have mine (and other people
                      who have views similar to mine).
                      [color=blue][color=green]
                      > > What people reffer to
                      > > is the separation of programming code from the markup.[/color]
                      >
                      > So...is that your defintion too? Some template engines claim
                      > separation of dynamic code from static code---for which they just use
                      > another markup (instead of <?=$foo?>) like {foo} or [foo] or
                      > <!--foo--> etc. In all cases, it is merely a *substitution* of PHP's
                      > template system with another one. Some template engines like Smarty
                      > claims separation of business logic from presentation logic---not
                      > separation of code; if you have tried Smarty you might be knowing
                      > that.
                      >
                      > All template engines use pull or push logic. So, the intution is
                      > why not use PHP which is also a template system? It seems you claim
                      > using <?=$foo?> in PHP developed web application is bad; but if we use
                      > {foo} it is ok. So, it sounds that we may use ASP code as a markup in
                      > PHP and vice-versa---and this argument is completely silly, IMHO.[/color]

                      I have tried Smarty, and I know how it works. For my taste, template system
                      should separate markup from the progrmaming code, and bussines logic should
                      be separated from presentation by usage of MVC or some other framework.

                      Using <?=$foo?> is pretty similar to {FOO}, but when you start to have
                      conditional pieces and loops, the things start to differ pretty radically.

                      I do not mind if someone prefers to intersparse php code along html, it's
                      their taste, and their choice. But in the same time, it would feel very
                      un-natural for me to do it that way. Again, who wants to have code inside
                      html I am fine with that, but just do not tell me this is the
                      _only_proper_wa y, and that it can not be done other way.
                      [color=blue]
                      > PHP itself is a template engine. Templating can be done with
                      > anything--even with PHP, which is fast & easy than other weird
                      > template markups.[/color]

                      Yap, you can say that it is. Only for my own use I find it to be a rather
                      nice and usable language/library and a less than perfect template system,
                      because it poorely separates code from the markup.

                      rush
                      --



                      Comment

                      • R. Rajesh Jeba Anbiah

                        #12
                        Re: to template or not

                        "rush" <pipa@rush.aval on.hr> wrote in message news:<c1f349$ou 9$1@ls219.htnet .hr>...
                        <snip>[color=blue]
                        > I have tried Smarty, and I know how it works. For my taste, template system
                        > should separate markup from the progrmaming code, and bussines logic should
                        > be separated from presentation by usage of MVC or some other framework.
                        >
                        > Using <?=$foo?> is pretty similar to {FOO}, but when you start to have
                        > conditional pieces and loops, the things start to differ pretty radically.[/color]

                        In this case, if you handle <?=$foo?> as the way you would handle
                        {foo} (ie, static), then the problem solved.

                        If you don't like the looping or conditioning inside the template,
                        you can just populate the list/content in the variable like
                        $foo_static_lis t and can just use it in the template. So, my point is
                        why making our own template engines to *just* to avoid looping &
                        conditioning---it can be done with PHP itself.

                        [color=blue]
                        > I do not mind if someone prefers to intersparse php code along html, it's
                        > their taste, and their choice. But in the same time, it would feel very
                        > un-natural for me to do it that way.[/color]

                        I don't mean adding conditioning & looping logic inside the
                        templates. I just say: why not use PHP's own markup instead of
                        inventing our own template markups, parser,.. And even I don't find
                        anything wrong with adding looping & conditioning inside the
                        templates--as long as presentation logic and business logic are
                        separated--Smarty's definition.
                        [color=blue]
                        > Again, who wants to have code inside
                        > html I am fine with that, but just do not tell me this is the
                        > _only_proper_wa y, and that it can not be done other way.
                        >[color=green]
                        > > PHP itself is a template engine. Templating can be done with
                        > > anything--even with PHP, which is fast & easy than other weird
                        > > template markups.[/color]
                        >
                        > Yap, you can say that it is. Only for my own use I find it to be a rather
                        > nice and usable language/library and a less than perfect template system,
                        > because it poorely separates code from the markup.[/color]

                        Most of the Designers use DW (at least here in India). PHP's own
                        markups are DW friendly. For example,

                        <td><?=$var1? ></td><td><?=$var2 ?></td>

                        In the above case, if the Designer wants to add some bit of
                        "colours", then it is easy for him to do so---'coz PHP codes will
                        never break up or mess up.

                        But, if you use other markups, it is possible that he may mess up
                        like:

                        <td>{var1}</td><td><b>{var2 </b>}</td> <--note the <b> tag

                        Well, you may claim that we can add our own markup to DW so that it
                        looks different. Yes, we can invent our own markup & add it---then why
                        if everything is available as cool and simple?

                        --
                        "Success is not what you achieve, but it is what you die for"
                        If you live in USA, please support John Edwards.
                        Email: rrjanbiah-at-Y!com

                        Comment

                        • rush

                          #13
                          Re: to template or not

                          "R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                          news:abc4d8b8.0 402242214.ec7dc 7c@posting.goog le.com...[color=blue]
                          > In this case, if you handle <?=$foo?> as the way you would handle
                          > {foo} (ie, static), then the problem solved.
                          >
                          > If you don't like the looping or conditioning inside the template,
                          > you can just populate the list/content in the variable like
                          > $foo_static_lis t and can just use it in the template. So, my point is
                          > why making our own template engines to *just* to avoid looping &
                          > conditioning---it can be done with PHP itself.[/color]

                          what if $foo_static_lis t needs to use other template, and conditions within,
                          and loops within condition, etc, which happens in most nicely designed
                          pages? What would be a clean way to populate it? Encode tha complex piece of
                          html as a string in php?
                          [color=blue]
                          > I don't mean adding conditioning & looping logic inside the
                          > templates. I just say: why not use PHP's own markup instead of
                          > inventing our own template markups, parser,.. And even I don't find
                          > anything wrong with adding looping & conditioning inside the
                          > templates--as long as presentation logic and business logic are
                          > separated--Smarty's definition.[/color]

                          Well, if that suits you fine. I do not like code that is intemixed with
                          html. For me it is hard to read, hard to write, and pain to maintain in the
                          same file together with designer. This is the reason I do not use php's own
                          markup, or templates that have programming constructs. If you find that
                          these reasons do not bother you, (and obviously they don't) than just write
                          the way you are.

                          On top of template system I separate presentation logic from bussines logic
                          by MVC or something similar, not by template system.
                          [color=blue]
                          > <td>{var1}</td><td><b>{var2 </b>}</td> <--note the <b> tag[/color]

                          If it starts happening to me I will think start thinking about it as a
                          problem. But what was happning to me, were the cases when designer cutted
                          away good pieces of php code, moved it in inproper places, or messed it up
                          inadverdently while changing the layout. And that is the problem I have
                          solved by usage of templates.

                          Again, I can understand that you do not prefer or do not have need to use
                          templates, I am fine with that. But just understand that I have a need for
                          them, and that they are for me powerfull and usable, and going back to not
                          use them would feel for me as going back into stone age.

                          rush
                          --



                          Comment

                          • Stephen Poley

                            #14
                            Re: to template or not

                            On Wed, 25 Feb 2004 14:02:32 +0100, "rush" <pipa@rush.aval on.hr> wrote:
                            [color=blue]
                            >"R. Rajesh Jeba Anbiah" <ng4rrjanbiah@r ediffmail.com> wrote in message
                            >news:abc4d8b8. 0402242214.ec7d c7c@posting.goo gle.com...[/color]
                            [color=blue][color=green]
                            >> I don't mean adding conditioning & looping logic inside the
                            >> templates. I just say: why not use PHP's own markup instead of
                            >> inventing our own template markups, parser,.. And even I don't find
                            >> anything wrong with adding looping & conditioning inside the
                            >> templates--as long as presentation logic and business logic are
                            >> separated--Smarty's definition.[/color]
                            >
                            >Well, if that suits you fine. I do not like code that is intemixed with
                            >html. For me it is hard to read, hard to write, and pain to maintain in the
                            >same file together with designer. This is the reason I do not use php's own
                            >markup, or templates that have programming constructs. If you find that
                            >these reasons do not bother you, (and obviously they don't) than just write
                            >the way you are.
                            >
                            >On top of template system I separate presentation logic from bussines logic
                            >by MVC or something similar, not by template system.
                            >[color=green]
                            >> <td>{var1}</td><td><b>{var2 </b>}</td> <--note the <b> tag[/color]
                            >
                            >If it starts happening to me I will think start thinking about it as a
                            >problem. But what was happning to me, were the cases when designer cutted
                            >away good pieces of php code, moved it in inproper places, or messed it up
                            >inadverdentl y while changing the layout. And that is the problem I have
                            >solved by usage of templates.[/color]

                            Just trying to understand this.

                            Suppose you have a page which has to display a variable-length list of
                            products. If the length is zero, it puts up a paragraph along the lines
                            of "no products currently available in this category".

                            How do you do that in a template which includes no code?

                            --
                            Stephen Poley

                            Comment

                            • rush

                              #15
                              Re: to template or not

                              "Stephen Poley" <sbpoleySpicedH amTrap@xs4all.n l> wrote in message
                              news:oj3s30tmvo 8sgs5a9rcc25il1 cs4bs6vni@4ax.c om...
                              [color=blue]
                              > Suppose you have a page which has to display a variable-length list of
                              > products. If the length is zero, it puts up a paragraph along the lines
                              > of "no products currently available in this category".
                              >
                              > How do you do that in a template which includes no code?[/color]

                              Hi, here is outline how would you do it with TT, on the web site there is a
                              number of examples starting from simpler to more complex ones, and if you
                              need more please mail me.

                              First here is html template file

                              html/prodlist.html:
                              <html>
                              <body>
                              <h1>Phone MegaStore Special</h1>

                              <!--NAME:ONEPRODUCT-->
                              Product Name:{PRODNAME} price: {PRODPRICE}<br> <hr>
                              <!--END:ONEPRODUCT-->

                              <!--NAME:NOPRODUCTS-->
                              Sorry no products found ...
                              <!--END:NOPRODUCTS-->

                              </body>
                              </html>

                              The ONEPRODUCT template contains html for each product row, and NOPRODUCTS
                              contains html for the case where you have no products at all. Now let's see
                              the php logic file that drives it:

                              logic/prodlist.logic. php:

                              <?PHP

                              class prodlist_Page extends TemplateTamer_P age {

                              function getData() {
                              $products = $this->getProducts( ); // let's suppose that getProducts
                              gets all products in array
                              if (size($products ) > 0) {
                              foreach($produc ts as $productName=>$ productPrice) {
                              $productList[] = array(
                              'PRODNAME' => $productName,
                              'PRODPRICE' => $productPrice
                              );
                              }
                              return array( 'ONEPRODUCT' => new RepeatTemplate( $productList) );
                              } else
                              return array( 'NOPRODUCTS' => array( ) );
                              }

                              function getProducts() {
                              // modify this fuction to get the actual product list ...
                              return array(
                              'Phones that work' => 100,
                              'Phones that do not work' = 1
                              );
                              }

                              }
                              ?>

                              rush
                              --



                              Comment

                              Working...