WordPress.org

Ready to get started?Download WordPress

Forums

Smarty (5 posts)

  1. alex
    Member
    Posted 10 years ago #

    WordPress has its own...bespoke templating system right now, it's not hugely nice or efficient or easy to use, Smarty is good, Smarty is nice, Smarty seperates code from interface. Yum. I also believe someone else if working on Smarty development atm.
    However the existing functions (the_content(), the_author() etc) are not really in keeping in the Smarty-way-of-doing-things. And as such, merely writing a Smarty wrapper for the existing templating functions isn't what you should really be doing. Instead, a rethink on the templating system would be much better.
    I am an OOP whore. And hence i suggest that we use either associative arrays as the primary method of displaying data through Smarty. These objects will have all the nice pre-processing done already. They will be accessed either using {section} or {foreach} within smarty. E.g. {foreach from=$posts item=post} <h3>{$post.title}</h3> {$post.content} {/foreach} You get the idea I hope. For fancy stuff like calendars, or possibly even permalinks and such custom functions and variable modifiers will be used. E.g. {archive_calendar} or {$post.id|permalink} or {$post.author|mailto}
    I don't have time to draw up an entirely descriptive design for this, but i hope you get the general idea of what im saying. the_content() is bad and evil and will eat your children if you dont watch it carefully.

  2. rayne
    Member
    Posted 10 years ago #

    I totally agree with this idea. Having the ability to use the loops that smarty supplies, the user has more flexibility in how they set up their pages. This will be especially useful to those users who are switching from Movable Type and are used to having maximum flexibility in their templates.

  3. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    You get more flexibility in Smarty than PHP? I think not. Smarty can be as flexible as PHP, but then you end up with just a metalanguage on top of PHP whose main advantage is having curly braces instead of opening and closing PHP tags. If we were to do a post loop, we would probably have a custom block function, so like:
    {posts cat="1" last="10"}
    <h2>{$title}<h2>
    {/posts}

    Or something of the like. Thanks for your comments.

  4. Alex King
    Member
    Posted 10 years ago #

    Re: foreach loops - you recognize we have a foreach loop for the posts and the comments already, correct?

  5. lars
    Member
    Posted 10 years ago #

    I agree with allusion and Moose.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.