× Warning! This forum is in archival status. New contributions may not work.
Did you update Smarty?
  • I am trying to solve a problem with the {{php}} tag not working in Newscoop 4.2.1. I notice on Smarty's website that this, and some others, were deprecated in Smarty 3.1. So my question is: was Smarty upgraded between Newscoop 4.2 and Newscoop 4.2.1, without using SmartyBC? 
  • 7 Comments sorted by
  • {{ $smarty.version }} tells me Smarty-3.0.9, so the deprecated features should still be available. What else could be causing this?
  • Vote Up0Vote Down Paweł MikołajczukPaweł Mikołajczuk
    Posts: 72Member, Sourcefabric Team
    Hey, we don't use BC and php tags are disabled by default. 
    You can enable it manualy with smarty security_settings.
  • So the default was changed in Newscoop 4.2.1. You need to change http://sourcefabric.booktype.pro/newscoop-42-cookbook/using-javascript-and-php-in-templates/ because it describes how it worked in Newscoop 4.2.

    How can I make that change? What files would I need to edit?
  • I added this line in template_engine/classes/CampTemplate.php, in the __construct() function:
    $this->allow_php_tag = true;

    The {{php}} tags in my template are now working.
  • Hi Sebastian,

    Can you give a full listing of a __construct() function with line "$this->allow_php_tag = true;"...

    Because I tried and get the error:

    1024:Newscoop:4.2:Smarty.class.php:697 Error String: Undefined property: CampTemplate::$allow_php_tag
    Error ID:


    Pavel
  •     public function __construct()
        {
            parent::__construct();

            $config = CampSite::GetConfigInstance();

            $this->debugging = $config->getSetting('smarty.debugging');
            $this->force_compile = $config->getSetting('smarty.force_compile');
            $this->compile_check = $config->getSetting('smarty.compile_check');
            $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs');

            // cache settings
            $cacheHandler = SystemPref::Get('TemplateCacheHandler');
            $auth = Zend_Auth::getInstance();
            if ($cacheHandler) {
                $this->caching = 1;
                $this->caching_type = 'newscoop';
                CampTemplateCache::factory();
            } else {
                $this->caching = 0;
            }

            if (self::isDevelopment()) {
                $this->force_compile = true;
            }

            // define dynamic uncached block
            require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php';
            $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false);

            // define render function
            require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php';
            $this->registerPlugin('function', 'render', 'smarty_function_render', false);

            $this->left_delimiter = '{{';
            $this->right_delimiter = '}}';
            $this->auto_literal = false;

            $this->cache_dir = APPLICATION_PATH . '/../cache';
            $this->compile_dir = APPLICATION_PATH . '/../cache';

            $this->plugins_dir = array_merge(
                (array) $this->plugins_dir,
                array(APPLICATION_PATH . self::PLUGINS),
                self::getPluginsPluginsDir()
            );

            $this->setTemplateDir(array(
                APPLICATION_PATH . '/../themes/',
                APPLICATION_PATH . '/../themes/unassigned/system_templates/',
                APPLICATION_PATH . self::SCRIPTS,
            ));

            if (isset($GLOBALS['controller'])) {
                $this->assign('view', $GLOBALS['controller']->view);
            }

            $this->assign('userindex', false);
            $this->assign('user', new MetaUser());

    // Allow PHP tags in templates
    $this->allow_php_tag = true;

        }

  • Thank you Sebastian ))

    It shout be last one ))

    Worked and for me ))