Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty 3.0: initial discussion
Goto page Previous  1, 2, 3 ... , 10, 11, 12  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7281
Location: Lincoln Nebraska, USA

PostPosted: Tue Sep 02, 2008 3:31 pm    Post subject: Re: Is this happening? Reply with quote

marcello.duarte wrote:
Is there any roadmap/milestones for this project yet?


Not yet, I'm willing to support such initiation if developers want to jump in?
Back to top
View user's profile Send private message Visit poster's website
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Tue Sep 02, 2008 10:07 pm    Post subject: Reply with quote

Do you have any idea of the magnitude of this task? To me it sounds like it would have to be a complete rewrite.
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7281
Location: Lincoln Nebraska, USA

PostPosted: Tue Sep 02, 2008 10:39 pm    Post subject: Reply with quote

Yes it would probably be a fairly large rewrite.
Back to top
View user's profile Send private message Visit poster's website
Celeb
Administrator


Joined: 17 Apr 2007
Posts: 1025
Location: Vienna

PostPosted: Wed Sep 03, 2008 7:58 am    Post subject: Reply with quote

Well, I'm not sure if that's worth the effort but if you decide to go through with it, I'd contribute one or two lines of code to make it happen Smile
_________________
Darn computers always do what I tell them to instead of what I want them to do.
Back to top
View user's profile Send private message
HJack
Smarty Rookie


Joined: 12 Aug 2008
Posts: 9

PostPosted: Fri Sep 05, 2008 7:51 am    Post subject: Reply with quote

Why re-invent the wheel?

http://dwoo.org/home

Why don't work together to make just one, better, template engine?

Take care Wink
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 259

PostPosted: Fri Sep 05, 2008 8:29 am    Post subject: Reply with quote

HJack wrote:
Why re-invent the wheel?

http://dwoo.org/home

Why don't work together to make just one, better, template engine?


Yeah, that's my words some posts ago - we don't need another Smarty fork like Template lite.

The author of dwoo, Jordi 'Seldaek' Boggiano, should be invited to work on future Smarty versions.
Back to top
View user's profile Send private message
Seldaek
Smarty n00b


Joined: 04 Mar 2008
Posts: 1

PostPosted: Fri Sep 05, 2008 4:41 pm    Post subject: Reply with quote

Heya,

elpmis wrote:
we don't need another Smarty fork like Template lite.


I couldn't agree more, especially given how Template Lite turned out -afaik it is not any faster than Smarty but quite the contrary.

That being said, Dwoo is not a Smarty fork. It uses the Smarty template syntax but that's it, everything has been written from scratch. It took me quite a lot of time in the past 8 or so months, and my early attempt of collaborating on this with the Smarty devs hasn't been very welcomed, so now that I am finally approaching 1.0 I don't really feel like merging with the Smarty project anymore.

Besides I don't think having full compatibility with Smarty2.x is a good thing, some stuff had to go and I guess everyone wouldn't agree with me on this. So.. Dwoo is there, 1.0beta is coming real soon, and I'm all ears if you want to discuss features, architectural changes or whatever, but as for using it as a basis for Smarty3 no thanks.

Cheers,
Jordi
Back to top
View user's profile Send private message
Ancient
Smarty Pro


Joined: 07 Jul 2007
Posts: 197
Location: Omaha, Nebraska, United States of America

PostPosted: Tue Sep 23, 2008 3:13 am    Post subject: Reply with quote

It's been awhile since this topic was made. Is there any progress in the last few months atleast?

PHP5 compatablility would be great.
Maybe the PHP Devs would look upon Smarty a little better?

Is there an estimated season the software will be released?
_________________
Smarty all the way.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
x!sign.dll
Smarty n00b


Joined: 31 Aug 2008
Posts: 3

PostPosted: Tue Sep 23, 2008 3:40 am    Post subject: Reply with quote

Well... read the last 20 posts and you will get your answer Smile
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7281
Location: Lincoln Nebraska, USA

PostPosted: Tue Sep 23, 2008 4:02 am    Post subject: Reply with quote

Things are progressing, see here:

http://www.phpinsider.com/smarty-forum/viewtopic.php?t=14168
Back to top
View user's profile Send private message Visit poster's website
sunflare
Smarty n00b


Joined: 22 Oct 2008
Posts: 2

PostPosted: Wed Oct 22, 2008 3:10 pm    Post subject: Extended foreach core functionality Reply with quote

I extended the core class Smarty_Compiler.class.php with some simple lines that are (I think) very useful.
Maybe there is a smarter syntax Smile but it worked for me.
It would be very nice if we could find this little extension in one of the next releases!

Purpose of the extension:
Sometimes you need a function in a foreach to split table rows after e.g. 4 displayed <td>
If you put a variable items=4 in a foreach, the function itself could compute if there has to be a <tr> opened or closed.
You can even find out, if there are some <td> missing in the last line, when the number of items is not divisible without remainder.

Code:

X  X  X  X  ->new row by close and open value (0 or 1)
X  X  X  X  ->new row by close and open value (0 or 1)
X  X  -  -  -> remain = 2 but only with a value in the last line == foreach.last


Code:

Around line 1188


        if (isset($attrs['name'])) {
            $name = $attrs['name'];
        } else {
            $name = null;
        }

//NEW - ITEMS
$no_of_items = $attrs['items'];

        $output = '<?php ';
        $output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
        if (isset($name)) {


Code:

Around line 2032

                    case 'show':
                        array_shift($indexes);
                        $compiled_ref = "(\$this->_foreach[$_var]['total'] > 0)";
                        break;
//NEW X

                    case 'remain':
                        array_shift($indexes);
                        //$compiled_ref = "(\$this->_foreach[$_var]['items'] - (\$this->_foreach[$_var]['total'] % \$this->_foreach[$_var]['items']))";
                        $compiled_ref = "(\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'] ? ";
                        $compiled_ref .= "( \$this->_foreach[$_var]['items'] != (\$this->_foreach[$_var]['items'] - (\$this->_foreach[$_var]['total'] % \$this->_foreach[$_var]['items'])) ?  (\$this->_foreach[$_var]['items'] - (\$this->_foreach[$_var]['total'] % \$this->_foreach[$_var]['items']))  : 0 )";
                        $compiled_ref .= " : 0 )";
                        //$compiled_ref = "0";
                        break;

//{if $x % $up_images_per_row  == 0}

                    case 'open':
                        array_shift($indexes);
                        $compiled_ref = "((\$this->_foreach[$_var]['iteration']-1) % \$this->_foreach[$_var]['items'] == 0)";
                        break;
//{if ($x % #MATCHES_IN_A_ROW#) == (#MATCHES_IN_A_ROW# - 1)}</tr>{/if}

                    case 'close':
                        array_shift($indexes);
                        $compiled_ref = "(   ((\$this->_foreach[$_var]['iteration']-1) % \$this->_foreach[$_var]['items'] == \$this->_foreach[$_var]['items'] - 1) or (\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'])  )";
                        break;


This gives you the opportunity to set a variable, how many items e.g. in a table should be in one row, opening a <tr> by "open" and closing it by "close". The remain variable (accessible through $smarty.foreach.fe.remain) shows the number of items that are not processed by the foreach
Example: You need a table with filled <td>
Code:

X  X  X  X  ->new row by close and open
X  X  X  X
X  X  -  -  -> remain = 2


In Smarty - I want three cells in one row and just for the case my array is not divisible without remainder but I need the cells:
Code:

<table border=1>
{foreach from=$arr item=y key=x items=3 name="fe2"}
{if $smarty.foreach.fe2.open}<tr>{/if}
<td>{$y.id}</td><td style="color:red">Debug:#{$smarty.foreach.fe2.items}#{$smarty.foreach.fe2.open}/{$smarty.foreach.fe2.close}/{$smarty.foreach.fe2.remain}</td>
{if $smarty.foreach.fe2.remain}{smarty_string_repeat times=$smarty.foreach.fe2.remain what="<td>XX</td><td>XX</td>"}{/if}
{if $smarty.foreach.fe2.close}</tr>{/if}
{/foreach}
</table>


Hope you can need this small info

Greetings
Jochen / Germany
Back to top
View user's profile Send private message Send e-mail
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7281
Location: Lincoln Nebraska, USA

PostPosted: Wed Oct 22, 2008 4:03 pm    Post subject: Reply with quote

There are many ways to accomplish this without hacking the compiler.

One is use {html_table} to format your data. See the docs.

Another is use a for or foreach loop, and use:

{if $foo is div by $cols}...{/if}

to structure your <tr> tags. There are lots of examples all over this forum.
Back to top
View user's profile Send private message Visit poster's website
sunflare
Smarty n00b


Joined: 22 Oct 2008
Posts: 2

PostPosted: Wed Oct 22, 2008 4:42 pm    Post subject: Reply with quote

Hello!

Thanks for your reply.
You are right, html_table can do the job but if you need more complicated td operations (nested tds divs etc)...

I used to do it like you said
Code:

<table>
{foreach from=$arr item=y key=x}
{if ($x % #MATCHES_IN_A_ROW#) == 0}<tr>{/if}
<td>Blabla</td>
{if ($x % #MATCHES_IN_A_ROW#) == (#MATCHES_IN_A_ROW# - 1)}</tr>{/if}
</table>


but I found it sometimes too much thinking Smile
Especially the remain thing.
Back to top
View user's profile Send private message Send e-mail
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 539

PostPosted: Wed Nov 12, 2008 2:04 pm    Post subject: Reply with quote

mohrt,

Sorry if i missed it, but I noticed in the README it says something about a lexing tokenizer allowing function recursion. Could you say a a little about how function recursion would look in Smarty?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7281
Location: Lincoln Nebraska, USA

PostPosted: Wed Nov 12, 2008 2:52 pm    Post subject: Reply with quote

douglassdavis wrote:
mohrt,

Sorry if i missed it, but I noticed in the README it says something about a lexing tokenizer allowing function recursion. Could you say a a little about how function recursion would look in Smarty?


For instance, object/function params:

{$foo->bar($foo->bar($foo->bar()))}
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty Development All times are GMT
Goto page Previous  1, 2, 3 ... , 10, 11, 12  Next
Page 11 of 12

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP