SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 49
  1. #1
    SitePoint Guru
    Join Date
    Feb 2002
    Posts
    625
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Interesting Article concerning templates

    read this

    I have to say, this article reminded me a lot about a discussion we had some time ago concerning templates.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Interesting ? Indeed - I have to say yes to the point made at the end about seperating business layer from the presentation layer.

    But alas, also I disagree about putting PHP syntax into markup, so exactly where this article stands from my point of view, I don't know LoL

    But then again since I don't advocate putting PHP syntax into a template, that's not to say the next person that comes along agrees w/ me though....

    As for smarty well, what can you say about it ? Bloatware just screams out at you LoL

  3. #3
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, hardly anything wich hasn't been said before (i remember at least one very good thread about templates here at Sitepoint).

    I personally am more against than for templates without wanting to condemn templates per se. There are situation where they make sense.

    One good point (mentioned in the article) to keep in mind, though, is:

    In short, the point of template engines should be to separate your business logic from your presentation logic, not separate your PHP code from your HTML code.
    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  4. #4
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am still an advocate now of XML/XSLT, though I need a good/better way to generate the XML pages which have the page data.
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  5. #5
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Theiggsta, speaking of this, how do you do that currently? The lack of good tools is one of the points which keeps me from using the xml/xslt way yet.

  6. #6
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its been said before, but their isn't much point in converting your MySQL data to XML, then on to xHTML or PDF. There are plenty of scripts out there that can make PDF or WAP files using regular PHP code.
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  7. #7
    SitePoint Addict
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    216
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know that there isn't much point in that. But I think it would be a challenge to change my whole working approach. Mind you, I would be willing to do that if the rewards were truly convincing.
    But one of the things that keeps me yet from doing it is that I could throw away my beloved dreamweaver (and all my other standard tools with it, as far as I see it). No advanced coding features, no assistance with designing any template stuff anymore. If I'd find some great (and cost effective) tools, maybe I would start completely anew, make all my pages in xml from scratch. I think tools like Altova's "Authentic" are a step in the right direction. Because obviously you need not only a tool to design your static pages with xml, but also a tool for your cms where you can have users type in sth easily without caring about xml.
    But right now I'm not ready to jump on the band wagon yet.

  8. #8
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, I agree with Trav, what is the bloddy point of using xml files to store data that is constantly changing and being read (I see the point in using them when you needn't to read/insert data often), after all, databases are just text files that store the data in organised way so that you can quickly get/insert/update/delete data from them, why invent your own?
    - website

  9. #9
    "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)
    and I don't get why people get data from MySQL in XML format...

    MySQL -> XML -> Parse XML back into usable data...
    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.

  10. #10
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe, do people really do that?

    like we say here in iceland:
    "Heimur versnandi fer"
    (the world is getting worse)
    - website

  11. #11
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and I don't get why people get data from MySQL in XML format...

    MySQL -> XML -> Parse XML back into usable data...
    Didn't read the article. But I can tell you that when you need to get the data to something that doesn't have native database access in useable way, returning query results in XML format is exactly what you need. For instance getting recordsets into flash for one.

  12. #12
    "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)
    true. in some cases it is required, and that is understandable. PHP isn't one of those cases.
    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.

  13. #13
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fair enough.

  14. #14
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You take the mysql data and make a living XML document with all the changed data, your XSLT stylesheet does the rest.

    And its not as slow as everyone thinks, its a matter of ms which is tons faster than smarty(smarty runs at 75 to 200 sometimes depending on how big your templates are).

    I think its a much simpler way and allows much mroe flexibility because the data is already there, the XSL just needs to make it pretty.
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  15. #15
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm not trouncing in here to advocate .NET, as I read the article with great interest, however .NET is the only solution I'm aware of that lets you separate both the HTML from the logic, as well as teh business and the presentation logic, which are both very important parts of any large-scale web project, if it's to survive past the typical 2-3 year lifecycle.

    For instance, imagine if you could (for a moment) completely separate those 3 oft-integrated components: actual HTML, presentational logic and business logic.

    At any time you could rewrite entire, or parts (depending on how you'd designed your app of course... I'm assumign we're all smart enough to design modularly, right?) of your business logic without affecting your presentation logic.

    Likewise, you should (where most tempalte engines actually fall short) be able to write your entire HTML structure without any worries about the presentational logic.

    And, extending that, you should be able to change your presentational logic without touching either the actual HTML or the business logic.

    To me, that's what a templating engine is meant to do: allow the 3 classes of "Developers" (html, web and application) to work completely independently and yet as a team.

    If there are any other solutions out there which allow this (I hear J2EE does to a degree, though I haven't seen examples of this, even in the Java PetStore example), I'd love to see them.

    Hopefully new versions of PHP means that these kinds of systems will be available for PHP as well. Choice is good for all of us

    J
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  16. #16
    "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 was working on a PHP-DOM style templating system a while back, where a template would look like the following:

    Code:
    <select server:id="someId" name="someId">
    </select>
    and that gets parsed into an object with methods like reading the innerHTML, innerText, insertAdjacentHTML, etc. I never really finished it, but I may still work on it at some point.
    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.

  17. #17
    SitePoint Addict -TheDarkEye-'s Avatar
    Join Date
    Mar 2001
    Location
    canada
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Trav
    Its been said before, but their isn't much point in converting your MySQL data to XML, then on to xHTML or PDF. There are plenty of scripts out there that can make PDF or WAP files using regular PHP code.
    i dont disagree with you but what if...

    1. you want to allow anyone/everyone to write "tempates" for you.
    2. you want to use a standardized markup so that you dont have to waste your time writing lots of documentation/examples/specs.
    3. you want to supply your template writers with a chunk of data to work with; you dont want them to have the ability to get whatever data they want.

    ??


    Jeremy W,

    J2EE can do that now that it has custom tags. CFMX can also do that; although, i dont see many people who take advantage of it.

  18. #18
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is completely possible to separate presentation logic from business logic without using templates.

    If you attempt to separate Business Logic from presentation logic by putting the presentation logic into a template language, then the template language has to be as complicated as the language used to express the business logic.

    The article author says "smarty has it closest to right", but also says "[smarty is] simply too big."

    Any language capable of expressing complicated presentation logic will by necessity be a full language on its own, and therefore big.

    What do you gain by using templates to separate presentation logic and business logic using templates that you do not gain by separating them using PHP?

    One benefit mentioned for templates is the ability to allow "HTML designers with no PHP experience to modify the look of the site without having to look at any PHP code."

    Moving presentation logic (including ifs and loops) into a template file negates this benefit.

    I have clients who are very comfortable editing PHPLIB style templates themselves who refuse to touch files created by smarty that has any kind of complicated logic in it.

    If a required change in presentation requires a change in presentation logic (changing ifs and loops) and my html designer does not understand programming (ifs and loops), the it does not matter if the logic is in a template file or in a php file, it is still going to require a programmer to make the change.

    In my book, there are strong arguments for separating PHP code into one file, and HTML markup into a different file.

    There are also strong arguments for separating presentation logic into one file and business logic into a different file.

    You can acheive both by having two PHP files and one HTML file.

    I do not see the value in putting presentation logic in the html file. (The smarty approach.)

  19. #19
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .NET basically copied Java and made it work a whole lot better by simplifying the process of development. I guess a big round of applause to whoever thought about that at MS. If you don't believe me, read the JSP documentation, .NET is litterally a MS'd style copy of the exact same thing. JSPs are compiled on the fly into java code, they also support tag libraries which run code on the backend.

    I guess I should become a .NET developer, seems to be the right thing to do now. Java has gotten so complicated that I need a dictionary for all the Acronyms(no joke).

    And yes I am a full-advocate of the next-generation MVC pattern which is so greatly done in Jakartas Struts project, all PHP devs who profess the separation of various logic should use that as a case study, then follow its lead. Seriously... Java might not be the best language in the world, but that project has it where it counts, a very scalable application design. Though I think people take PHP a little too seriously and treat it like some enterprise development language when all it is really capable of is simple scripting and emulating enterprise languages. If you want to be serious, check into Java or .NET (preferably .NET, you'll get a massive headache with Java).

    The beauty of the Struts project is that your data and logic is already done and you can choose whatever you want as your "View" part which is basically some sort of templating system. You have a choice of using JSP by default or modifying it to use XSLT(Its incredibily easy to dump data into an XML file in Java for XSLT transformation, you basically serialize a object into XML data and presto your done, never have to worry about heavily modifying code to shove the data into another container) or you can use a Java templating system like Velocity. I am not telling everyone here to go grab a Java book, just showing you that Java has great examples of the correct way to do things (not language wise but by just design patterns) and we should all be taking some notes(im referring to .NET and PHP devs alike).
    Last edited by Theiggsta; May 6, 2003 at 06:04.
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  20. #20
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Personally like the article - makes the point about seperation of presentation logic from application logic well which is, IMO, a different problem to providing a "designer friendly" mechanism for customizing the look and feel of a site.

    The presentation logic is usually not completely the realm of a designer to deal; in fact think it's mainly the job of the developer to decide what happens there. The problem is there isn't a clear divide between who does what and what each should be expected to know.

    I think there are effectively three generations of approach solving this;

    1st Generation: Smarty etc which create their own language - this includes XSLT IMO. They are all characterized by having programming language type syntax e.g.;

    Code:
    {if:x=y}
    <p>Hello</p>
    {else}
    <p>Goodbye</p>
    {endif}
    2nd Generation: I think these are distinguished by using classes to handle all the logic of the presentation layer and bind it to the application logic layer.

    The result makes the templates pretty minimalistic and encourages seperation of presentation logic from application logic.

    There's only two examples of what I'd called 2nd generation template systems that I know of.

    The first is ASP.NET. Here's an example;

    Code:
    <table width="100%" cellpadding=0 cellspacing=0 >
    <tr>
    <th>Title</th>
    <th>Author</th>
    <th>Date</th>
    </tr>
    <asp:repeater id="ArticlesListing"  runat="server">
    <tr>
    <td>
    <%# DataBinder.Eval(Container.DataItem, "Title") %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem, "Author") %>
    </td>
    <td>
    <%# DataBinder.Eval(Container.DataItem, "Date") %>
    </td>
    </tr>
    </asp:repeater>
    </table>
    What happens when the .NET template parser reads the above template is it first encounters this tag;

    Code:
    <asp:repeater id="ArticlesListing"  runat="server">
    In response to the tag it instantiates the Repeater class which is a presentation logic class. The Repeater object then instantiates the ArticlesListing class which is an application logic class which will be used to fetch article data.

    Inside the opening and closing <asp:repeater /> element, all elements found there will be used to build the output for as many rows as the ArticlesListing class delivers.

    Also inside the repeater section of the template are tags like this;

    Code:
    <%# DataBinder.Eval(Container.DataItem, "Title") %>
    This is essentially what extracts elements from an ArticlesListing row and implants them in the page. I guess "DataBinder" is a Singleton object, globally available, and "Container" is the object reference that the Repeater class instance is stored in, while "Container.DataItem" is where the reference to the instance of the ArticlesListing class is stored.

    We're still talking a language here which a designer would have to learn but it's got an XML-like syntax which in many ways infers the control structures. The tags refer to presentation logic classes which solve practically all common template related operations - and that's where the money comes home for MS - by having a well defined set of tags and classes for templates, they can then sell tools which make web page design a question of "drag and drop" - that's compelling reason to use ASP.NET because it makes life alot easier. It's worth noting the PHP has no such tool - there are PHP editors which are good for PHP source but where are the drag and drop page designers? The problem is PHP doesn't have a standard set of presentation logic classes, which .NET does. Even outside of PHP, I've found no page design tools that allow you to layout a page but define your own tags which your own template parser will use to load classes for handling the tags. That surprises me to be honest - there's only a limited set of widgets and control structures associated with an HTML page - why someone hasn't designed an editor that allows you to specify your own tag naming convention I don't know.

    Don't let that sound like doom and gloom for PHP though. Remember ASP.NET is a templating language just like any other, in the end. If it can be parsed by .NET and can be parsed by anything. What sort of parser MS use I'm not 100% sure - it may be DOM based or SAX based but I am sure it's some form of XML parser. I've tried a variety of approaches with DOM so far, none of which I've been satisfied with - PHP's DOM still isn't stable enough for this problem. But SAX wise things are looking good - using SAX filters, as with <html><a href="http://www.phppatterns.com/index.php/article/articleview/48/1/2/" target="_blank">converting XUL to PHP-GTK</a></html> it's very doable - I'm working on a prototype right now which can already to simple things with ASP.NET pages. I'm not going to reproduce the entire .NET presentation logic classes but I'm hoping to get it to a point where it can be easily extended then perhaps submit to PEAR and see what happens. The big incentive for doing this one is to make the ASP.NET web design tools available to PHP coders.

    The other second generation template system I know of is eZ publish 3.x. Here's an example equivalent to the .NET example;

    Code:
    <table width="100%" cellpadding=0 cellspacing=0 >
    <tr>
    <th>Title</th>
    <th>Author</th>
    <th>Date</th>
    </tr>
    {section name=ArticleItem loop=$article.items}
    <tr>
    <td>
    {$article:ArticleItem:item.title}
    </td>
    <td>
    {$article:ArticleItem:item.author}
    </td>
    <td>
    {$article:ArticleItem:item.date}
    </td>
    </tr>
    {section show=$article:ArticleItem:item.item_object.option_list}
    </table>
    It may look like old style template syntax but eveything is being handled by classes in a pretty similar manner to ASP.NET - control structures are encapsulated inside classes.

    They don't have a widget class library like ASP.NET yet and in this area, fall back to "1st Generation" templating e.g.

    Code:
    <form>
    {include uri="design/gui:combobox.tpl"}
    </form>
    Where combobox.tpl looks like;

    Code:
    <select name="{$id_name}">
    {section name=combobox loop=$list}
    <option value="{$combobox:item.id}"
        {switch name=sw match=$combobox:item.id}
        {case match=$current}selected{/case}
        {/switch}>
    {$combobox:item.name}
    </option>
    {/section}
    </select>
    Having said that, if eZ systems get the time they could probably also develop a drag and drop IDE for eZ publish, assuming they construct a standard set of basic "widget" templates or better yet, write native PHP classes to do the same.

    The main difference between ASP.NET and eZ publish 3.0 in terms of how the templates are used is with ASP.NET, everything begins with the template - the template tells .NET which classes to load and where to get started.

    eZ publish begins with the request URI and uses it to decide which template to load, which in turn specifies the application logic classes. In short eZ publish is an MVC framework while ASP.NET isn't.

    Read somewhere in the Petshop wars that MS don't believe MVC is a good approach for web applications - they may have a point as implementing an MVC architecture means taking control of serving pages away from the web server and handling it in your code. For a Java Servlet this is required but if you've already got a web server, why re-invent the wheel?

    The problem with both of these template systems is there's alot of syntax to learn, which makes them fairly difficult to hand code but for MS it means they can sell their tools.

    As to the Java Standard Template Library, by my definition I think I'd call that a generation 1.5 system - there's still plenty of control structures placed in the template itself.

    3rd Generation: Pure CSS. If web browsers all support CSS fully, the whole problem basically does away. As web developers we can simply output a ton of <div /> elements and nothing else. A web designer then has full control over layout using a CSS page e.g.;

    Code:
    <div id="articleTable">
     <div id="headerRow">
      <div id="headerRowTitle">Title</div>
      <div id="headerRowAuthor">Author</div>
      <div id="headerRowDate">Date</div>
     </div>
     <div id="articleRow">
      <div id="articleRowTitle">Build your own database driven...</div>
      <div id="articleRowAuthor">Kevin Yank</div>
      <div id="articleRowDate">12th February 2001</div>
     </div>
     <div id="articleRow">
      <div id="articleRowTitle">Another article</div>
      <div id="articleRowAuthor">Someone</div>
      <div id="articleRowDate">13th June 2002</div>
     </div>
    </div>
    Using CSS, a designer has complete control over the positioning and look and feel of the above "table". My guess is you could probably do it already with Mozilla. If you check the source of Simon Wilson's weblog: http://simon.incutio.com/ he's pretty much doing this already.

    Of course we don't have to reduce everything to <div /> tags - right now we'd still need the form elements but I wonder when you'll be able to determine how an element looks with CSS?

    The above example could be;

    Code:
    <table id="articleTable">
     <tr id="headerRow">
      <td id="headerRowTitle">Title</td>
      <td id="headerRowAuthor">Author</td>
      <td id="headerRowDate">Date</td>
     </tr>
     <tr id="articleRow">
      <td id="articleRowTitle">Build your own database driven...</td>
      <td id="articleRowAuthor">Kevin Yank</td>
      <td id="articleRowDate">12th February 2001</td>
     </tr>
     <tr id="articleRow">
      <td id="articleRowTitle">Another article</td>
      <td id="articleRowAuthor">Someone</td>
      <td id="articleRowDate">13th June 2002</td>
     </tr>
    </table>
    The designer still has complete control but the developer is now a big more involved in the design process, deciding what type of tags should be used.

    More importantly, the designer now has absolutely no part in what goes on in the presentation logic layer - it's up to the developer to make the division between application and presentation logic correctly - the designer purely does layout, look and feel. The template engine can now be thrown out of the window - this can be done with pure PHP.

    The problem today is IE doesn't fully support CSS and perhaps CSS needs another version anyway to give designers everything they need.

    Phew - long rant - looking back still don't think I've got this one fully pegged.

  21. #21
    Wanna-be Apple nut silver trophy M. Johansson's Avatar
    Join Date
    Sep 2000
    Location
    Halmstad, Sweden
    Posts
    7,400
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't struts kind of the same as the ASP.NET Web Forms framework? I haven't looked at struts too closely, but I would love to know what the differences are!
    Mattias Johansson
    Short, Swedish, Web Developer

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

  22. #22
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,121
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Harry's starting to understand .NET, but is still a long way off... :sigh:
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  23. #23
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And yes I am a full-advocate of the next-generation MVC pattern which is so greatly done in Jakartas Struts project, all PHP devs who profess the separation of various logic should use that as a case study, then follow its lead.
    Exactly where can we see this I wonder ? You do have a URL ? 8)

    HarryF - your idea sound good though isn't PEAR bloated enough ? LoL....

  24. #24
    SitePoint Guru
    Join Date
    Oct 2001
    Posts
    656
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://jakarta.apache.org/struts

    Struts is nice, but it's too limiting if you ask me. It feels too 'static', you have to hardcode every one of your Actions and Views in an XML file...

  25. #25
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Harry's starting to understand .NET, but is still a long way off... :sigh:
    If it's wrong tell me where. One thing on further review that's not quite right is this;

    The Repeater object then instantiates the ArticlesListing class which is an application logic class which will be used to fetch article data.
    After reviewing some of the sample code as asp.net, ArticlesList would also be an application logic class which is already instantiated at the top of the page. ArticlesList is just the reference to the object, declared with something like;

    Code:
    public HtmlContainerControl ArticleList;
    Seems you have to bind the data to this in the first place to be able to access it later within the template.

    Would be interested to see a simple version of the ASP.NET template above backed with some C#.

    Isn't struts kind of the same as the ASP.NET Web Forms framework? I haven't looked at struts too closely, but I would love to know what the differences are!
    I kinda touched on that in the above post (you got there moments later);

    Read somewhere in the Petshop wars that MS don't believe MVC is a good approach for web applications - they may have a point as implementing an MVC architecture means taking control of serving pages away from the web server and handling it in your code. For a Java Servlet this is required but if you've already got a web server, why re-invent the wheel?
    For me struts is characterized by there being a central piece of code/PHP script which is the first point of contact for all page requests. This script works out the next level of decision making that has to be made then calls the code to make the decision, which in turn calls more code and so on. Perhaps the measure of struts is how form validation can be handled - you can submit a form to a completely different URL within the site and still have it validated.

    My understanding of Web Forms, in terms of how MS expect you to use it is the form validation will happen via the same script that rendered the form in the first place as shown here. This is much like PEAR::QuickForm. Of course that doesn't tie you to doing it this way - you could write your own version of struts using Web Forms (as you could with QuickForm if that's your pleasure) but you'd have to seperate the validation from the presentation of the form.

    Struts has the advantage that once you know how it's being implemented, it provides a very rigorous and flexible framework to build on. But it's often very complex; the abstractions it introduces is not going to appeal to someone who only knows a little HTML. Struts I guess is a product of Java Servlets, which may be an important detail.

    I guess eZ publish 3.0 is now a form of struts - check out how they handle validation, for example, it seems to be on a completely site wide basis depending on the custom data type you use / define (e.g. data type "eZEmail" is automatically validated every time an email address is received from any form, anywhere). There's certainly a pretty steep learning curve for developers with ezp3 although for site administrators, it's Content Class system is extremely powerful.

    But who knows - MS may be right that MVC (the struts architecture) is wrong for web sites, given that a web server has an in built "decision making" mechanism which will pass requests for the right page to the right script. This is certainly a down to earth approach which makes it easy to find the code which handles a request.

    For PHP, been thinking perhaps we should throw out the whole idea of using index.php as a central place for all incoming requests and instead use the php.ini setting "auto_prepend_file" to handle all "global" operations such as loading general data access layer classes and user authentication while leaving the specifics that happen at a particular URL to the script that resides there. That could also include form validation at a "global" level. That approach would be perhaps ideal if you're not using an application framework like eZ publish.

    Back to basics. Whoohoo!


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
  •