View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Sep 02, 2008 3:31 pm Post subject: Re: Is this happening? |
|
|
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 |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Tue Sep 02, 2008 10:07 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Sep 02, 2008 10:39 pm Post subject: |
|
|
Yes it would probably be a fairly large rewrite. |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Wed Sep 03, 2008 7:58 am Post subject: |
|
|
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 _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
HJack Smarty Rookie
Joined: 12 Aug 2008 Posts: 9
|
Posted: Fri Sep 05, 2008 7:51 am Post subject: |
|
|
Why re-invent the wheel?
http://dwoo.org/home
Why don't work together to make just one, better, template engine?
Take care |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
Posted: Fri Sep 05, 2008 8:29 am Post subject: |
|
|
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 |
|
Seldaek Smarty n00b
Joined: 04 Mar 2008 Posts: 1
|
Posted: Fri Sep 05, 2008 4:41 pm Post subject: |
|
|
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 |
|
Ancient Smarty Pro
Joined: 07 Jul 2007 Posts: 196 Location: Omaha, Nebraska, United States of America
|
Posted: Tue Sep 23, 2008 3:13 am Post subject: |
|
|
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 |
|
x!sign.dll Smarty n00b
Joined: 31 Aug 2008 Posts: 3 Location: https://www.xsigndll.com
|
Posted: Tue Sep 23, 2008 3:40 am Post subject: |
|
|
Well... read the last 20 posts and you will get your answer |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
sunflare Smarty n00b
Joined: 22 Oct 2008 Posts: 2
|
Posted: Wed Oct 22, 2008 3:10 pm Post subject: Extended foreach core functionality |
|
|
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 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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Oct 22, 2008 4:03 pm Post subject: |
|
|
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 |
|
sunflare Smarty n00b
Joined: 22 Oct 2008 Posts: 2
|
Posted: Wed Oct 22, 2008 4:42 pm Post subject: |
|
|
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
Especially the remain thing. |
|
Back to top |
|
douglassdavis Smarty Junkie
Joined: 21 Jan 2008 Posts: 541
|
Posted: Wed Nov 12, 2008 2:04 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Nov 12, 2008 2:52 pm Post subject: |
|
|
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 |
|
|