This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » General discussion » Smarty view
Re: Smarty view [message #14786 is a reply to message #14744 ] Fri, 27 October 2006 13:47 Go to previous messageGo to next message
roychri  is currently offline roychri
Messages: 14
Registered: September 2006
Location: Blainville, Qc, Canada
Junior Member

I am in a rush at work at the moment and doing lots of overtime.
I'll take a look as soon as things calm down here.


Christian Roy
Zend Certified PHP5 Programmer
* Nothing is impossible, the impossible just takes longer! *
Re: Smarty view [message #14856 is a reply to message #574 ] Sat, 28 October 2006 15:38 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
We didn't actually say on which monday we are going to compare our results, did we Wink

But I am doing some coding at the moment, maybe it will be next monday, hopefully...
Re: Smarty view [message #17771 is a reply to message #14856 ] Tue, 12 December 2006 23:06 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
haha, next monday...

ok, but now there is a new version:
http://www.symfony-project.com/trac/wiki/sfSmartyViewPlugin

the pear install from http://plugins.symfony-project.com doesn't work at the moment, but otherwise it should work well, if you download it and then run
$symfony plugin-install sfSmartyView-0.1.1.tgz

[Updated on: Tue, 12 December 2006 23:08]

Re: Smarty view [message #18008 is a reply to message #574 ] Sat, 16 December 2006 00:04 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
ok, and the installation from the plugin site is now working also
$ ./symfony plugin-install http://plugins.symfony-project.com/sfSmartyViewPlugin
does the trick
Re: Smarty view [message #20190 is a reply to message #574 ] Mon, 22 January 2007 21:34 Go to previous messageGo to next message
Kyle  is currently offline Kyle
Messages: 7
Registered: January 2007
Junior Member
Hi GeG!

Yesterday I installed the sfSmartyView Plugin and it works. But I had to solve some issues:

Your readme file doesn't mention where to store the Smarty (class)-Files. I stored them in plugins/sfSmartyViewPlugin/lib/Smarty and I hope that was your intention Wink. (I use Smarty 2.6.14)

To install sfSmartyView as a Plugin i had to install the latest beta version of symfony. But sfSmartyView conflicts with changes made in r2953. The sfView attributes $attribute_holder and $parameter_holder were renamed to $attributeHolder and $parameterHolder.

Only some helpers are missing.

Kyle

[Updated on: Mon, 22 January 2007 21:44]

Re: Smarty view [message #20231 is a reply to message #20190 ] Tue, 23 January 2007 11:03 Go to previous messageGo to next message
chiba  is currently offline chiba
Messages: 3
Registered: January 2007
Junior Member
Quote:

To install sfSmartyView as a Plugin i had to install the latest beta version of symfony. But sfSmartyView conflicts with changes made in r2953. The sfView attributes $attribute_holder and $parameter_holder were renamed to $attributeHolder and $parameterHolder.


I want to use accessor(getAttributeHolder()).
Because a variable name will be changed again.
I made a patch.

--- sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php.orig	Tue Jan 23 18:16:31 2007
+++ sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php	Tue Jan 23 18:22:52 2007
@@ -105,15 +105,15 @@
         self::$smarty->clear_all_assign();
         $_escaping = $this->getEscaping();
         if ($_escaping === false) {
-            self::$smarty->assign($this->attribute_holder->getAll());
+            self::$smarty->assign($this->getAttributeHolder()->getAll());
         } elseif ($_escaping == 'both') {
-            $sf_data = sfOutputEscaper::escape($this->getEscapingMethod(), $this->attribute_holder->getAll());
+            $sf_data = sfOutputEscaper::escape($this->getEscapingMethod(), $this->getAttributeHolder()->getAll());
             $sf_data['sf_data'] = $sf_data;
             self::$smarty->assign($sf_data);
         } else {
-            $sf_data = sfOutputEscaper::escape($this->getEscapingMethod(), $this->attribute_holder->getAll());
-            $this->attribute_holder->add(array('sf_data' => $sf_data));
-            self::$smarty->assign($this->attribute_holder->getAll());
+            $sf_data = sfOutputEscaper::escape($this->getEscapingMethod(), $this->getAttributeHolder()->getAll());
+            $this->getAttributeHolder()->add(array('sf_data' => $sf_data));
+            self::$smarty->assign($this->getAttributeHolder()->getAll());
         }
         $er = error_reporting();
         if ($er > E_STRICT) {

Re: Smarty view [message #20233 is a reply to message #20190 ] Tue, 23 January 2007 11:04 Go to previous messageGo to next message
chiba  is currently offline chiba
Messages: 3
Registered: January 2007
Junior Member
oops. I submitted duplicate message.

[Updated on: Tue, 23 January 2007 11:14]

Re: Smarty view [message #20359 is a reply to message #20231 ] Wed, 24 January 2007 20:56 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
double post Sad this forum is too slow for me!

[Updated on: Wed, 24 January 2007 20:59]

Re: Smarty view [message #20360 is a reply to message #20231 ] Wed, 24 January 2007 20:58 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
@chiba: thanks for the patch, I have included it in version 0.1.3

@Kyle: I have included the config vars in the documentation, including the path to the smarty file.
BTW which helpers are you missing?
Re: Smarty view [message #20370 is a reply to message #20360 ] Thu, 25 January 2007 04:18 Go to previous messageGo to next message
chiba  is currently offline chiba
Messages: 3
Registered: January 2007
Junior Member
Hi Geg.
I'm Japanese and cannot use English so well.

_GeG_ wrote on Wed, 24 January 2007 20:58

@chiba: thanks for the patch, I have included it in version 0.1.3

@Kyle: I have included the config vars in the documentation, including the path to the smarty file.
BTW which helpers are you missing?

maybe, that is appearing exeptions when symfony's SF_ENVIRONMENT set to "dev".

Unable to load "SmartyHelperHelper.php" helper ....

this exeption occuring in loadHelper().
        try {
            sfLoader::loadHelpers(array($helperName, 'Smarty' . $helperName));
        }

Using "set_error_handler" when symfony's SF_ENVIRONMENT set to "dev".
Then although using try ,sfTestBrowserErrorHandler catch the error and write log.

This problem doesn't really matter.

But if somebody feel uneasy then use this patch.
--- sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php.orig	Thu Jan 25 11:31:27 2007
+++ sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php	Thu Jan 25 12:09:51 2007
@@ -172,7 +172,12 @@
         }
         include (self::$cache->getFile($helperName, self::CACHENAMESPACE));
         try {
-            sfLoader::loadHelpers(array($helperName, 'Smarty' . $helperName));
+            if (self::isExistSmartyHelper($helperName)) {
+                sfLoader::loadHelpers(array($helperName, 'Smarty' . $helperName));
+            }
+            else {
+                sfLoader::loadHelpers(array($helperName));
+            }
         }
         catch (sfViewException $e) {
             if (!strpos($e->getMessage(), 'Smarty' . $helperName)) {
@@ -182,6 +187,21 @@
         self::$loadedHelpers[$helperName] = true;
     }
 
+    /*
+     * @param string $helperName
+     * @return boolean
+     */
+    private function isExistSmartyHelper($helperName) {
+        if ($pluginHelperDirs = glob(sfConfig::get('sf_plugins_dir').'/*/lib/helper') ) {
+            foreach ($pluginHelperDirs as $pluginHelperDir) {
+                if (is_readable($pluginHelperDir . '/Smarty' . $helperName . 'Helper.php')) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }    
+    
     /**
      * sfSmartyView::parseFile()
      *



Maybe best way(for performance) is make "SmartyHelperClass array"
and using array_key_exists in isExistSmartyHelper.

[Updated on: Thu, 25 January 2007 04:53]

Re: Smarty view [message #20398 is a reply to message #20370 ] Thu, 25 January 2007 22:31 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
Hi chiba,

I have to look into this, I haven't had this problem so far. Thanks for the patch.
Re: Smarty view [message #20414 is a reply to message #574 ] Fri, 26 January 2007 13:29 Go to previous messageGo to next message
al_n  is currently offline al_n
Messages: 321
Registered: May 2006
Location: The Netherlands
Faithful Member
I took an easier approach to use Smarty in Symfony.
I created a my own Smarty view which just initialize a smarty object called $smarty to be used inside a Symfony template.
Then from inside the template I'm doing the assignments and at the end calling the display method, like:
$smarty->assign('x', 'y');
$smarty->display('template.tpl');

If you want to use it then the stripped view class is attached. Just put your smarty templates in your apps/appName/modules/modulName/templates/smarty directory and use the pre-initialized $smarty object as described.

Re: Smarty view [message #20488 is a reply to message #574 ] Sun, 28 January 2007 23:53 Go to previous messageGo to next message
Kyle  is currently offline Kyle
Messages: 7
Registered: January 2007
Junior Member
@ GeG / chiba

Yes, I found some exceptions in my log file when symfony tried to load the standard helpers but didn't found the smarty helpers like SmartyHelperHelper.php and SmartyUrlHelper.php etc. I think its good practice to load the "normal" symfony helpers if there is no smarty helper available (like chibas patch does), but finally we should cover all helper functions with smarty helpers. Helper functions and files which are not coverd with smarty helpers will be accessible through {php}-tags only (or am I wrong?).

@al_n
That may be a good solution for you Smile. But you'll have a greater effort if you're adding or changing variables which requires you to change at least 2 documents. The symfony helper functions will be another problem for your approach, I think. If you want to access them, you've to use {php}-Tags (or do you have another solution?). But that won't work for me for example. I want to have a strict division between layout and business logic with minimum maintenance effort.


@thread
I found another "problem": Deleting symfonys cache directory causes an exception when SmartyView tries to create it's cache and compile directory. I don't know if *nix systems allow to create two directories "/Smarty/compile" at once, but my Windows won't. I made a patch:

Index: sfSmartyView.class.php
===================================================================
--- sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php.orig	Sun Jan 28 23:40:12 2007
+++ sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php	Sun Jan 28 23:44:27 2007
@@ -61,17 +61,29 @@
             self::$templateSecurity = sfConfig::get('app_sfSmartyView_template_security', false);
             self::$smarty->security = self::$templateSecurity;
             self::$log = sfConfig::get('sf_logging_enabled')? $this->getContext()->getLogger() : false;
+
+            // creating smarty subdir if not exists
+            if (!file_exists($smartyDirs)) {
+                if (!mkdir($smartyDirs, 0777, true)) {
+                    throw new sfCacheException('Unable to create cache directory "' . $smartyDirs . '"');
+                }
+                if (self::$log) self::$log->info('{sfSmartyView} creating smarty cache directory: ' . $smartyDirs);
+            }
+
+            // creating compile dir
             if (!file_exists(self::$smarty->compile_dir)) {
                 if (!mkdir(self::$smarty->compile_dir, 0777, true)) {
                     throw new sfCacheException('Unable to create cache directory "' . self::$smarty->compile_dir . '"');
                 }
                 if (self::$log) self::$log->info('{sfSmartyView} creating compile directory: ' . self::$smarty->compile_dir);
             }
+
+            // creating cache dir
             if (!file_exists(self::$smarty->cache_dir)) {
                 if (!mkdir(self::$smarty->cache_dir, 0777, true)) {
                     throw new sfCacheException('Unable to create cache directory "' . self::$smarty->cache_dir . '"');
                 }
-                if (self::$log) self::$log->info('{sfSmartyView} creating compile directory: ' . self::$smarty->cache_dir);
+                if (self::$log) self::$log->info('{sfSmartyView} creating cache directory: ' . self::$smarty->cache_dir);
             }
             self::$smarty->register_compiler_function('use', array($this, 'smartyCompilerfunctionUse'));
             self::$smarty->register_postfilter(array('sfSmartyView', 'smartyPostFilter'));


Kyle

[Updated on: Sun, 28 January 2007 23:54]

Re: Smarty view [message #20520 is a reply to message #20488 ] Mon, 29 January 2007 15:25 Go to previous messageGo to next message
Kyle  is currently offline Kyle
Messages: 7
Registered: January 2007
Junior Member
Hi there!

Shame on me, I didn't see the generic helper parser. Ok, there's no helper missing Wink.

I played a little bit with symfony helper functions. The __() i18n helper function will be ignored (because it's starting with an underscore). Perhaps you'll fix this with the following patch:

--- sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php.orig    Thu Jan 28 23:44:27 2007
+++ sfSmartyViewPlugin-0.1.2\lib\sfSmartyView.class.php    Thu Jan 29 14:40:31 2007
@@ -198,7 +210,7 @@
             if (strpos($line, 'function') === 0) {
                 preg_match('/function\\s+(\\w+)\\s*\\((.*)\\)\\s*\\{?$/', $line, $matches);
                 $name = $matches[1];
-                if ($name{0} == '_') {
+                if ($name{0} == '_' && $name !== '__') {
                     continue;
                 }
                 $code .= "\nself::\$knownFunctions['$name']=";




@GeG Why did you write the SmartyJavascriptHelper? What was your aim? The javascript-Block causes an exception if i reload the page because the helper will be cached and smartys register-block-function won't be called again. So smarty can't find the block and triggers an error.

Kyle
Re: Smarty view [message #20649 is a reply to message #574 ] Wed, 31 January 2007 11:35 Go to previous messageGo to next message
tohenk  is currently offline tohenk
Messages: 5
Registered: January 2007
Location: Indonesia
Junior Member
Hi all,

I have a look at Smarty Plugin and there is still no support for partial view using Smarty.

I have rewrite the plugin to support this partial. Unfortunately, symfony doesn't have any configuration to support another partial view. So PartialHelper.php also must be modified to accept configuration, say it 'partial_view_class'.

To use Smarty Partial view define (in module.yml):
all:
  ...
  view_class:           sfSmarty
  partial_view_class:   sfSmartyPartial
  ...



tohenk.

[Updated on: Wed, 28 February 2007 16:53]

Re: Smarty view [message #20726 is a reply to message #20649 ] Thu, 01 February 2007 12:34 Go to previous messageGo to next message
tohenk  is currently offline tohenk
Messages: 5
Registered: January 2007
Location: Indonesia
Junior Member
Hi again.

I have attached the other change for SmartyView plugin.
sfSmartyUtil now become static.


Regard.

Re: Smarty view [message #22559 is a reply to message #574 ] Tue, 27 February 2007 06:46 Go to previous messageGo to next message
johnny  is currently offline johnny
Messages: 5
Registered: February 2007
Location: Russia, Barnaul
Junior Member
Hello,

I newbee in Symfony, but use another framework with Smarty.

Can you say how can I include helpers in templates instead of:
<?php use_helper('Object') ?>

?

I can insert 'Object' helper to standart_helpers in settings.yml and then it works. But if i use:
{use_helper helper="Object"} then tags from that helper not works.

Can you help?
Re: Smarty view [message #22565 is a reply to message #22559 ] Tue, 27 February 2007 07:40 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
Hi johnny,

as you can read in the README.pdf, you can use a helper with
{use helper='Object'}
Re: Smarty view [message #22590 is a reply to message #22565 ] Tue, 27 February 2007 13:18 Go to previous messageGo to next message
johnny  is currently offline johnny
Messages: 5
Registered: February 2007
Location: Russia, Barnaul
Junior Member
If i using : {use helper='Object'}
then i get error: sfSmartyUtils: Cannot compile template. Use: {use helper="helpername"}

But if i use: {use helper="Object"}
it will try to include helper SmartyObjectHelper.

How can i use symfony helpers?

I.e. code:
{use helper="I18N"}
{__ text="test"}

i get error:
Fatal error: Smarty error: [in file:/var/www/person/johnny/modno/apps/frontend/modules/prof ile/templates/listSuccess.tpl line 9]: syntax error: unrecognized tag '__' (Smarty_Compiler.class.php, line 583) in /var/www/person/johnny/modno/lib/smarty/Smarty.class.php on line 1088
Re: Smarty view [message #22677 is a reply to message #22590 ] Wed, 28 February 2007 16:49 Go to previous messageGo to next message
tohenk  is currently offline tohenk
Messages: 5
Registered: January 2007
Location: Indonesia
Junior Member
Hi johnny,

It seems, you've used modified sfSmartyPlugin.
Try to patch sfSmartyUtils.class.php with this patch.

--- C:\Temp\sfSmartyUtils.class.php.new	Mon Feb 12 14:13:39 2007
+++ C:\Temp\sfSmartyUtils.class.php	Thu Feb 01 14:52:24 2007
@@ -372,7 +372,6 @@
             throw new Exception('sfSmartyUtils: Cannot compile template. Use: {use helper="helpername"}');
         }
         self::loadHelper($matches[1]);
-        self::registerSmartyFunctions($smarty);
         return '';
     }
 


Regards.

tohenk

[Updated on: Wed, 28 February 2007 16:59]

Re: Smarty view [message #22721 is a reply to message #22677 ] Thu, 01 March 2007 09:24 Go to previous messageGo to next message
johnny  is currently offline johnny
Messages: 5
Registered: February 2007
Location: Russia, Barnaul
Junior Member
Thanks,

But, I add line: self::registerSmartyFunctions($smarty); and now it works
Re: Smarty view [message #23691 is a reply to message #14744 ] Thu, 15 March 2007 08:10 Go to previous messageGo to next message
WeBMaN  is currently offline WeBMaN
Messages: 60
Registered: February 2007
Location: Kazakhstan
Member

thx i find it
Re: Smarty view [message #24855 is a reply to message #574 ] Mon, 02 April 2007 10:04 Go to previous messageGo to next message
johnny  is currently offline johnny
Messages: 5
Registered: February 2007
Location: Russia, Barnaul
Junior Member
Is anybody made sfMailView with Smarty support?
Re: Smarty view [message #24945 is a reply to message #24855 ] Mon, 02 April 2007 20:39 Go to previous messageGo to next message
_GeG_  is currently offline _GeG_
Messages: 45
Registered: October 2005
Location: In front of the screen
Member
What is that?
Re: Smarty view [message #24964 is a reply to message #24945 ] Tue, 03 April 2007 05:09 Go to previous messageGo to next message
johnny  is currently offline johnny
Messages: 5
Registered: February 2007
Location: Russia, Barnaul
Junior Member
It used for sending emails from actions:

$raw_email = $this->sendEmail('mail', 'sendPassword');

but it cannot support smarty tags in templates with installed sfSmartyViewPlugin.

Can anybody help me? Maybe some configuration in .yml needed?
Re: Smarty view [message #25194 is a reply to message #24964 ] Thu, 05 April 2007 12:21 Go to previous messageGo to next message
Kyle  is currently offline Kyle
Messages: 7
Registered: January 2007
Junior Member
@ tohenk

I think I found another bug in your PartialView: If you have two partials the (core and standard) helpers aren't loaded in the second one. Each partial gets a new Smarty instance. The first partial sets sfSmartyPartialView::$registered to true. The second partial gets a complete new Smarty instance but sfSmartyUtils::registerSmartyFunctions(...) won't be called. Just call sfSmartyUtils::fetchTemplate($smarty, $this, $file) in sfSmartyPartialView's renderFile(...) mehtod and omit $registered to solve this problem.


@johnny

It's not that easy. It's similar to the PartialView: You've to modify some symfony core files and you have to create another class sfSmartyMailView which is a subclass of sfMailView.
The view class for mails is set in sfController's method sendEmail(...). Perhaps i'll find some time next week to write sfSmartyMailView or someone else is faster Wink.

Kyle
Re: Smarty view [message #25256 is a reply to message #574 ] Thu, 05 April 2007 23:35 Go to previous messageGo to next message
sjohnr  is currently offline sjohnr
Messages: 36
Registered: September 2006
Member
To be clear, I'd like to applaud those of you who have done work on this little project. However, my comment after viewing some of the issues discussed in this thread, is that the Smarty Plugin for symfony seems to be off track from what a plugin should be. Needing to modify symfony core just to get your plugin to work seems contrary to the point of a plugin.

I remember when the design of the Smarty Plugin was being discussed, and my opinion would be that some of it went wrong at that point.

This isn't a particularly important comment for you worry about, but if someone wants to discuss why it is acceptable to require modification of symfony core code just to get this plugin to work, I'd be interested in that discussion.

Sorry to be such a stick-in-the-mud.
Re: Smarty view [message #26341 is a reply to message #574 ] Thu, 26 April 2007 18:19 Go to previous messageGo to next message
WarriorDeluxe  is currently offline WarriorDeluxe
Messages: 1
Registered: April 2007
Junior Member
Hi @all,

I'm new to symfony and I want to use smarty for templating. So I'm glad that there is a plugin for it Smile

But if I use the example code from the readme.pdf I get this error when reloading the page:

Fatal error: Smarty error: [in file:D:\...\trunk\apps\frontend\modules/default/templates/indexSuccess.tpl line 7]: [plugin] could not load plugin file 'block.javascript.php' (core.load_plugins.php, line 118) in D:\...\trunk\lib\Smarty\Smarty.class.php on line 1095


after I clear the cache this error dissapear until the next reload.
any suggestions?
Re: Smarty view [message #29699 is a reply to message #574 ] Tue, 19 June 2007 05:02 Go to previous messageGo to next message
port  is currently offline port
Messages: 408
Registered: February 2007
Location: Dayton, Ohio, USA
Faithful Member
Dear Friends:

I must say that the discussion and team work (which has been going nearly non-stop for two years between people from different places around the world) is a testament, not only to the php / symfony community, but to the internet and how it is flattening the world out and making it a whole lot smaller.

I'm amazed--

BTW--I came to the thread because I'm going to create a plugin for haml and was gleaning any pointer I could from the discussion.

Port


"What if I stumble, what if I fall?
What if I lose my step and I make fools of us all?
Will the love continue when my walk becomes a crawl?
What if I stumble, and what if I fall?" -- DC Talk
Re: Smarty view [message #38445 is a reply to message #574 ] Wed, 31 October 2007 13:38 Go to previous messageGo to next message
ditman  is currently offline ditman
Messages: 36
Registered: August 2007
Location: Spain
Member
Hi there!!

How is this plugin going? I've looked at the TRAC, but it's been quite a long time since the last version came out (jan 2007 maybe?).

Is anyone still working on Smarty for Symfony? Or is this going to be "core" functionality in next versions of the framework?? Smile

Keep this up!! Very Happy


David Iglesias Teixeira
Indigo IT Developer
Re: Smarty view [message #39570 is a reply to message #574 ] Thu, 15 November 2007 14:51 Go to previous messageGo to next message
lexor  is currently offline lexor
Messages: 3
Registered: November 2007
Location: Moldova, Chisinau
Junior Member
Is it possible to use automatic admin interface (based on generator.yml) with this plugin? All works nice for common templates and CRUD, but not for this. I get an exception
sfRenderException:
The template "/listSuccess.tpl" does not exist in:
stack trace
...

Hope for your help, thanks!


Imagination is more important than knowledge (Albert Einstein)
Re: Smarty view [message #39586 is a reply to message #39570 ] Thu, 15 November 2007 17:39 Go to previous messageGo to next message
Kyle  is currently offline Kyle
Messages: 7
Registered: January 2007
Junior Member
Hi guys!

sjohnr wrote:

To be clear, I'd like to applaud those of you who have done work on this little project. However, my comment after viewing some of the issues discussed in this thread, is that the Smarty Plugin for symfony seems to be off track from what a plugin should be. Needing to modify symfony core just to get your plugin to work seems contrary to the point of a plugin.



I agree with you, that changing symfony's core files is nothing a plugin should do. But in my opinion this is a lack of symfony itself. On one hand symfony provides the possibility to add / use a custom template system like smarty - on the other hand this is only possible for normal templates but impossible to configure for mails and partials. There is already a open ticket for that issue: http://trac.symfony-project.com/ticket/2035



@WarriorDeluxe
Did you solve your problem?



ditman wrote:


How is this plugin going? I've looked at the TRAC, but it's been quite a long time since the last version came out (jan 2007 maybe?).

Is anyone still working on Smarty for Symfony? Or is this going to be "core" functionality in next versions of the framework??


I use the plugin in my current developments and it is working fine at the moment. Of course the mail-class is missing but i found it easier to write mail templates the symfony way than writing a SmartyMailView class for the smarty plugin. Is there somebody interested in that SmartyMailView class?



lexor wrote:


Is it possible to use automatic admin interface (based on generator.yml) with this plugin? All works nice for common templates and CRUD, but not for this. I get an exception
sfRenderException:
The template "/listSuccess.tpl" does not exist in:
stack trace
...


No, i'm sorry. The admin generator creates dynamic "templates" designed for symfony which use symfony helpers, variables and other stuff in symfonys standard-syntax. Enabling the smarty view plugin requires using these the "smarty-way". The admin generator is hard-coded (lib/symfony/generator/sfAdminGenerator.class.php). If you wan't to enable smarty in admin interface you've to rewrite it.

I'm not sure if the following is right. Feel free to correct me:
Another problem is the dynamic part: Admin generator writes dynamic templates at runtime and executes them. In the dynamic templates php-commands will be used. When i'm working with smarty i disable the use of php commands in templates (due to security reasons). That means these templates won't work.


Kyle
Re: Smarty view [message #39849 is a reply to message #39586 ] Mon, 19 November 2007 16:54 Go to previous messageGo to next message
spatterson  is currently offline spatterson
Messages: 8
Registered: November 2007
Junior Member
Hi, I am trying to install the plugin and I'm encountering errors. When I run the command symfony plugin-install http://plugins.symfony-project.com/sfSmartyViewPlugin, I get the following messages:

>> dir+ /home/spatterson/workspace/AFI/plugins/.channels/.alias

Warning: file_put_contents(/home/spatterson/workspace/AFI/plugins/.ch annels/pear.symfony-project.com.reg): failed to open stream: No such file or directory in /usr/share/php5/symfony/data/tasks/sfPakePlugins.php on line 225

Warning: file_put_contents(/home/spatterson/workspace/AFI/plugins/.ch annels/.alias/symfony.txt): failed to open stream: No such file or directory in /usr/share/php5/symfony/data/tasks/sfPakePlugins.php on line 226
>> dir+ /home/spatterson/workspace/AFI/...hannel.pear.symfony-projec t.com

Warning: file_put_contents(/home/spatterson/workspace/AFI/plugins/.re gistry/.channel.pear.symfony-project.com/symfony.reg): failed to open stream: No such file or directory in /usr/share/php5/symfony/data/tasks/sfPakePlugins.php on line 242
>> plugin installing plugin "http://plugi...project.com/sfSmartyViewPlugin"
>> pear downloading sfSmartyViewPlugin-0.1.3.tgz ...
>> pear Could not download from
>> pear "http://plugins.symfony-project.com/sfSmartyViewPlugin"
>> pear Invalid or missing remote package file
>> pear Package
>> pear "http://plugins.symfony-project.com/sfSmartyViewPlugin" is not
>> pear valid


[Exception]
install failed



I have installed the full (non-sandbox) version of symfony and everything else is working as expected. Any suggestions as to the cause of this error would be appreciated
Re: Smarty view [message #39899 is a reply to message #39586 ] Tue, 20 November 2007 09:40 Go to previous messageGo to next message
ditman  is currently offline ditman
Messages: 36
Registered: August 2007
Location: Spain
Member
Kyle wrote on Thu, 15 November 2007 17:39

Hi guys!
on the other hand this is only possible for normal templates but impossible to configure for mails and partials. There is already a open ticket for that issue: http://trac.symfony-project.com/ticket/2035


I'll have a look at that ticket, but I managed to get Smarty partials working. Components, partials and slot look nice Smile You "only" need to add a class to handle them (I copypasted 99% of it from sfSmartyView).

What I did to call that class was creating my own helpers to include_smarty_partial and so on. Doesn't have the whole power of symfony, but it's close.

I think Smarty is slowing my development, but it was a requisite for my latest project Smile

By the way... Has anyone managed to build a link like this (using helpers, of course):

<?php print link_to(image_tag('img'), 'moule/action?param=value'); ?>

in smarty templates???

[Updated on: Tue, 20 November 2007 09:43]


David Iglesias Teixeira
Indigo IT Developer
Re: Smarty view [message #42644 is a reply to message #574 ] Thu, 03 January 2008 05:18 Go to previous messageGo to next message
jing  is currently offline jing
Messages: 1
Registered: January 2008
Junior Member
Hi,

Thank you for SmartyViewPlugin.
(I'm not good at English so please forgive my poor grammar and spelling mistakes.)

I'm trying to migrate my project to symfony with smarty.

There's a lot of code in my templates like this:


{include file="head.tpl"}
{include file="left.tpl"}
{include file="right.tpl"}
{include file="foot.tpl"}


Now I find that the Instance of Smarty Class in SmartyView can parse indexSuccess.tpl and layout.tpl well but failed to include
other templates.

I'v got default^%%06^060^060EF7CE%%layout.tpl.php after Smarty compiled layout.tpl.

I can see a line like this:

$this->_smarty_include(array('smarty_include_tpl_file' => "left.tpl", 'smarty_include_vars' => array()));

while run the page it shows

Warning: Smarty error: unable to read resource: "left.tpl" in path\apps\frontend\lib\Smarty\Smarty.class.php on line 1104

So I added a line in sfSmartyView.class.php


self::$smarty->template_dir = sfConfig::get('sf_app_template_dir', 'templates');


Then it works.

[Updated on: Thu, 03 January 2008 06:33]

to: WarriorDeluxe [message #45744 is a reply to message #574 ] Mon, 18 February 2008 15:43 Go to previous messageGo to next message
bjbs_270  is currently offline bjbs_270
Messages: 1
Registered: February 2008
Junior Member
about the problem "Fatal error: Smarty error: [in file:D:\apps\www\symfony\askeet\apps\frontend\modules/defaul t/templates/indexSuccess.tpl line 15]: [plugin] could not load plugin file 'block.javascript.php' (core.load_plugins.php, line 118) in D:\apps\www\symfony\askeet\lib\Smarty\libs\Smarty.class.php on line 1095 "

I have resolve it

please see my blog: http://blog.csdn.net/bjbs_270/archive/2008/02/18/2104346.asp x

you should create the file of block.javascript.php in lib\Smarty\libs\plugins

code content:
<?php
function smarty_block_javascript()
{
}
?>
Re: Smarty view [message #45794 is a reply to message #20414 ] Tue, 19 February 2008 09:19 Go to previous messageGo to next message
eaglebvro
Messages: 1
Registered: February 2008
Junior Member
Where should I put your class? In %SF_LIB_DIR%?
Re: Smarty view [message #46939 is a reply to message #574 ] Mon, 03 March 2008 14:27 Go to previous messageGo to next message
ahmedshaikhm  is currently offline ahmedshaikhm
Messages: 7
Registered: May 2007
Junior Member
I have got Symfony version 1.0.9, Smarty 2.6.19 And PHP 5.2.3 on Windows XP Professional with Apache 2.2.

apps/frontend/config/module.yml
all:
   view_class:       sfSmarty

apps/frontend/config/app.yml
all:
    sfSmartyView:
        class_path:               %sf_symfony_lib_dir%/vendor/smarty/libs/
        template_extension:       .tpl


indexSuccess.tpl and layout.tpl are same as sample that is {SYMFONYDIR}plugins\sfSmartyViewPlugin\templates

Action File
	public function executeIndex()
	{
        }


The error is weird. Any clue

Notice: Undefined property: sfSmartyView::$attribute_holder in {HIDDEN}\plugins\sfSmartyViewPlugin\lib\sfSmartyView.class.p hp on line 114

Fatal error: Call to a member function getAll() on a non-object in {HIDDEN}\plugins\sfSmartyViewPlugin\lib\sfSmartyView.class.p hp on line 114

log says:
Mar 03 18:30:08 symfony [info] {sfContext} initialization
Mar 03 18:30:09 symfony [info] {sfController} initialization
Mar 03 18:30:09 symfony [info] {sfRouting} match route [default] "/:module/:action/*"
Mar 03 18:30:09 symfony [info] {sfRequest} request parameters array (  'module' => 'list',  'action' => 'test',)
Mar 03 18:30:09 symfony [info] {sfController} dispatch request
Mar 03 18:30:09 symfony [info] {sfFilter} executing filter "sfRenderingFilter"
Mar 03 18:30:09 symfony [info] {sfFilter} executing filter "sfCommonFilter"
Mar 03 18:30:09 symfony [info] {sfFilter} executing filter "sfFlashFilter"
Mar 03 18:30:09 symfony [info] {sfFilter} executing filter "sfExecutionFilter"
Mar 03 18:30:09 symfony [info] {sfAction} call "listActions->executeTest()"
Mar 03 18:30:09 symfony [info] {sfView} initialize view for "list/test"
Mar 03 18:30:09 symfony [info] {sfSmartyView} is used for rendering
Mar 03 18:30:09 symfony [info] {sfSmartyView} renderFile {HIDDEN}\apps\frontend\modules/list/templates/testSuccess.tpl
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyHelperHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyUrlHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyAssetHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyPartialHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyCacheHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear
Mar 03 18:30:09 symfony [err] {sfViewException} Unable to load "SmartyFormHelper.php" helper in: {HIDDEN}\apps\frontend\lib/helper, {HIDDEN}\lib/helper, {HIDDEN}\plugins/sfSmartyViewPlugin/lib/helper, {HIDDEN}\config/../lib/symfony/helper, {HIDDEN}\lib, {HIDDEN}, {HIDDEN}\apps\frontend\lib, {HIDDEN}\config/../lib/symfony\vendor, ., E:\apache2triad\php\pear


Thanks in advance.

-Ahmed,

[Updated on: Mon, 03 March 2008 14:33]

Re: Smarty view [message #47069 is a reply to message #574 ] Wed, 05 March 2008 00:50 Go to previous messageGo to next message
globalpegasus  is currently offline globalpegasus
Messages: 1
Registered: March 2008
Junior Member
In response to ahmedshaikhm, try to verify that you use the latest version of SfSmartyViewPlugin ... because the command ./symfony plugin-install http://plugins.symfony-project.com/sfSmartyViewPlugin is retrieving the version 0.1.0 (and the latest is the 0.1.3).

If the problem persists, try to access using the development script (finished in *_dev.php) instead of index.php
Re: Smarty view [message #47103 is a reply to message #47069 ] Wed, 05 March 2008 14:14 Go to previous messageGo to previous message
ahmedshaikhm  is currently offline ahmedshaikhm
Messages: 7
Registered: May 2007
Junior Member
Hi thanks,

The issue was that AttributeHolder is being used older way in my versio of sfSmarty plugin, when I use the attribute-holder as written under sfPHPView, the issue got resolved.

thanks.

-Ahmed.
Previous Topic:How to get the form data?
Next Topic:Search bar question
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software