|
|
| Re: Smarty view [message #1158 is a reply to message #574 ] |
Fri, 16 December 2005 06:58   |
Ian Messages: 383 Registered: October 2005 Location: Boulder, CO (USA) |
Faithful Member |
|
|
I always found this to be a good article. I never found that template engines made much sense. Smarty is the closest by far, but what's the point, you can do it in PHP.
Ian
█ Join us on IRC for LIVE support!
█ Report bugs here.
|
|
|
|
|
| Re: Smarty view [message #1220 is a reply to message #1210 ] |
Mon, 19 December 2005 16:04   |
davedash Messages: 147 Registered: December 2005 |
Senior Member |
|
|
| psylence wrote on Mon, 19 December 2005 07:34 |
{php}
// uh oh!
{/php}
|
Well that can be turned off.
I suppose all-in-all, I as a developer prefer the syntax of smarty over PHP, not for non-developers, but because it's easy to take HTML that a designer has developed and integrate it using small smarty tags here and there...
but ultimately, I'd rather leave the actual template designs in a developer's hands... or someone who specializes in HTML.
http://reviewsby.us/ - Rate what you just ate.
http://spindrop.us/ - Open Source web consultant
|
|
|
|
|
|
|
|
|
|
|
| Re: Smarty view [message #4778 is a reply to message #574 ] |
Fri, 07 April 2006 20:33   |
eemece2 Messages: 3 Registered: April 2006 |
Junior Member |
|
|
Yes, I think also PHPTAL looks very promising.
eemece2
[Updated on: Fri, 07 April 2006 20:36]
|
|
|
|
|
|
| Re: Smarty view [message #6772 is a reply to message #574 ] |
Sun, 28 May 2006 17:57   |
dzejkej Messages: 64 Registered: May 2006 |
Member |
|
|
Any news about sfSmarty, GeG?
[Updated on: Mon, 29 May 2006 15:06] dzejkej is closed-source SVK human product
lazy man for professional web tools
|
|
|
|
|
|
| Re: Smarty view [message #8384 is a reply to message #574 ] |
Thu, 06 July 2006 04:06   |
|
I will ask for a plugin (sfSmarty) and try to get what is posted in the forum commited to svn... Possibly an install script with smarty. but time is tight so it might be a bit
|
|
|
|
|
| Re: Smarty view [message #12685 is a reply to message #574 ] |
Sun, 24 September 2006 22:44   |
sjohnr Messages: 36 Registered: September 2006 |
Member |
|
|
Ok, I've done some more research on this topic today, and am getting even more serious about it. I'm not yet ready to take the alpha code posted above (smartyView.zip) and run with it, because I sense some of you have been working on this since it was posted.
However, I would like to liven up this topic with some design discussion, unless anyone seriously objects this (but why would you??? ).
My line of thought (the reason I want smarty support in symfony) is template readability (plus, smarty just plain rocks). The drawback of symfony templates currently is they look ugly as heck.
The readme file suggests this to make a symfony helper call:
{$sf->link_to('add to cart','shoppingCart/add?id=%s','confirm=Are you sure?',$id)}
I propose that a smarty compiler plugin be created and added to the smarty deployment that creates a standardized way to include symfony template calls (like helper calls, etc.). This would also allow the whole "%s" business to go away, as we could embed php into this smarty function call, and it would be evaluated as php.
Here's an untested, super-duper beta version of such a smarty compiler plugin.
<?php
//compiler.sf.php
function smarty_compiler_sf($tag_attrs, &$compiler)
{
$_params = $compiler->_parse_attrs($tag_attrs);
if (!isset($_params['helper'])) {
$compiler->_syntax_error("sf: missing 'helper' parameter", E_USER_WARNING);
return;
}
$helper = $_params['helper'];
return "echo $helper";
}
?>
If this compiler function works as expected, you could then make symfony template specific calls like this:
{sf helper="link_to('my link','somewhere/action?id='.$id,array('some'=>'options','go'=>'here'))"}
which would evaluate in the compiled smarty template as:
<?php echo link_to('my link', 'somewhere/action?id='.$id,array('some'=>'options','go'=>'here')) ?>
or in general:
{sf helper="symfony_helpers_galore(...)"}
From here we can flesh out this idea all we want. Questions? Comments?
[Updated on: Mon, 25 September 2006 01:54]
|
|
|
| Re: Smarty view [message #12686 is a reply to message #574 ] |
Mon, 25 September 2006 02:08   |
sjohnr Messages: 36 Registered: September 2006 |
Member |
|
|
Alternately, we could seek other, more readable variants (which I mentioned was my whole interest in smarty for symfony).
A simpler smarty compiler function:
<?php
//compiler.sf.php
function smarty_compiler_sf($tag_attrs, &$compiler)
{
$_sf = trim($tag_attrs); //removes leading space
return "echo $_sf";
}
?>
could be used like:
{sf link_to('my link','somewhere/action?id='.$id,array('some'=>'options','go'=>'here'))}
which again outputs:
<?php echo link_to('my link', 'somewhere/action?id='.$id,array('some'=>'options','go'=>'here')) ?>
Notice that the parameters section is output as php (minus the leading space), but still provides us with a nice looking, standardized way of handling symfony template/helper calls, while still maintaining all the capabilities we had without smarty (concatenating strings, defining arrays, etc).
Another version I'm working on might be used like this:
{sf}link_to('my link','somewhere/action?id='.$id,array('some'=>'options','go'=>'here')){/sf}
Sorry for such long posts. Just throwing out ideas.
|
|
|
| Re: Smarty view [message #12687 is a reply to message #574 ] |
Mon, 25 September 2006 02:09   |
sjohnr Messages: 36 Registered: September 2006 |
Member |
|
|
|
server hangup...
[Updated on: Mon, 25 September 2006 05:47]
|
|
|
| Re: Smarty view [message #12816 is a reply to message #574 ] |
Tue, 26 September 2006 23:40   |
|
I am interested in using smarty with symfony and helping integrating it too.
Maybe we should form a gruop, someone should be the leader and assign tasks?
Let me know.
Christian Roy
Zend Certified PHP5 Programmer
* Nothing is impossible, the impossible just takes longer! *
|
|
|
|
| Re: Smarty view [message #13981 is a reply to message #13978 ] |
Mon, 16 October 2006 22:52   |
|
Hello Georg,
I am interested. I am studying the plugin system now.
I reviewed your code. I was about to convert into a plugin. Good timing 
Just like sjohnr, I think something more readable is possible.
I also wanted to modify your code to create someting more smarty-ish for the helpers.
{link_to url="user/list"}List of users{/link_to}
instead of :
{$sf->link_to("List of users", "user/list")}
For internationalisation, something like:
{t}Hello World{/t}
instead of:
{$sf->__("Hello World")}
Not sure why having sf (in {sf something} or {$sf->somthing}) is necessary.
We can also have a {use_helper helper="I18N"} which will call $smarty->register_*() functions so other helpers becomes available (loaded only as needed).
How do we go from here?
I can certainly create all necessary smarty_function_*() smarty plugins functions to mirror symfony helpers.
The only problem is to get application/module specific helpers callable by smarty as smarty plugins.
I am thinking about some kind of automatic function creation which create_function() which wrap the helper using relection.
Using reflection we can find out the helper's function name and arguments. We can then create a function on the fly which expect these parameters and pass them on to the function. This means any helper function for an application could be automatically available in smarty.
A helper like this:
function myhelper($foo, $bar=null)
{
// some code here
}
It would create something like:
function smarty_function_myhelper($params, &$smarty) {
if ( !isset($params["foo"]) ) {
$smarty->trigger_error("myhelper: missing 'foo' parameter");
return;
}
if ( !isset($params["bar"]) ) {
$params["bar"] = null;
}
myhelper($params["foo"], $params["bar"]);
}
Maybe the function created can be put in symfony cache/ so we do not have to use reflection in production but we can get ride of it using clear-cache.
Just some thoughts.
Would it help if the sfSmartyView plugin would have a mailing list, a cvs/svn repositatory, wiki page, etc... ? Just another thought 
Let me know what you think.
Thanks
Christian Roy
Christian Roy
Zend Certified PHP5 Programmer
* Nothing is impossible, the impossible just takes longer! *
|
|
|
|
|
| Re: Smarty view [message #14066 is a reply to message #14055 ] |
Tue, 17 October 2006 22:58   |
|
I'll be there.
According to timzone converter, 9pm MET would be 2PM EST.
Christian Roy
Zend Certified PHP5 Programmer
* Nothing is impossible, the impossible just takes longer! *
|
|
|
|
|
| Re: Smarty view [message #14354 is a reply to message #14133 ] |
Sat, 21 October 2006 17:59   |
sjohnr Messages: 36 Registered: September 2006 |
Member |
|
|
I read through the chat log. What you guys were saying seems to mimic my thoughts for the most part.
However we want to implement it in smarty, we should output code which is essentially a symfony template everyone is used to now. I also like the idea of automatically creating smarty functions that essentially mirror our helper functions, using reflection.
It was hard to catch everything (I was reading it in notepad, shame on me), so I'm not sure I can produce a prototype also, unless I read your chat six more times. However, I'm interested in being involved in creating some of the hard-coded mirror functions, like:
{link_to url="my/action"}text{/link_to}
and such. However you do it, make sure that we can reproduce every symfony version of a helper call in smarty to its entirety, including concatenating strings to build urls, etc.
Good work so far guys. Looking forward to the prototypes.
|
|
|
|
| Re: Smarty view [message #14367 is a reply to message #14357 ] |
Sun, 22 October 2006 04:35   |
sjohnr Messages: 36 Registered: September 2006 |
Member |
|
|
Well, let me rephrase. What you were talking about in the chat message seems to be on track for the most part.
1. Create several functions in smarty that cover the most general symfony helper functions (i.e. {link_to url="..."}text{/link_to}, etc.).
2. Use reflection and a smarty compiler function to generate php code for symfony helper functions which aren't in the predefined list.
Again, the chat message was a bit hard to read, and I don't want to read it again, but it sounds like you have some ideas already. All I was getting at is that we should have some capability to essentially embed php code into our smarty functions (which mirror symfony helper functions). For instance, if I want to have a link like "my/action?id=$id" this would need to be printed fairly literally in php so it can be evaluated (unless of course, someone has a better idea for creating arrays and evaluating strings, etc. in the smarty template).
Maybe, we should postpone the rest of this discussion until after you have posted the results of your preliminary prototypes. We'll actually have something tangible to discuss then.
Again, I applaud you for taking the time to come up with these prototypes. I'm excited.
|
|
|
|