Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6216509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:15:40+00:00 2026-05-24T07:15:40+00:00

Here is my directory structure: ./smartytest.php ./smarty31/* (libs, etc.) ./plugins/block.sayhi.php The PHP code that

  • 0

Here is my directory structure:

./smartytest.php
./smarty31/* (libs, etc.)
./plugins/block.sayhi.php

The PHP code that initializes smarty is:

require_once('smarty31/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = getcwd() . '/templates';
$smarty->compile_dir  = getcwd() . '/templates_c';
$smarty->plugins_dir[] = getcwd() . '/plugins';

The PHP code for the plugin is:

<?php
    function smarty_block_sayhi($params, $content, $smarty, $open) {
        if (!$open) {
            return 'Hello: ' . $content;
        }
    }
?>

The error message I get is this:

Fatal error: Uncaught exception ‘SmartyCompilerException’ with message
‘Syntax Error in template “/mypath/phptests/templates/page.tpl” on
line 11 “{sayhi}” unknown tag “sayhi”‘

When the plugin was under the smarty31/libs/plugins directory, it loaded fine. Does this sample code not initialize Smarty correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T07:15:41+00:00Added an answer on May 24, 2026 at 7:15 am
    $smarty->plugins_dir[] = getcwd() . '/plugins';
    

    Should be:

    $existing = $smarty->getPluginsDir();
    $existing[] = getcwd() . '/plugins';
    $smarty->setPluginsDir($existing);
    

    Turns out I was looking at a PHP 4 example; Smarty 3.1 uses PHP 5 access modifiers so I couldn’t change plugins_dir that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is directory structure /global.php /includes/class_bootstrap.php /includes/init.php /plugins/myplugin.php Here is codes in these files
So, examining this directory structure /include_one.php /include_two.php /directory/main_file.php Assume that I am in /directory/main_file.php
Here's my directory structure: -root --docs ---doc1.php --includes ---header.php ---footer.php ---css.css --index.php In my
So, here's a quick extract of the directory structure on a web application that
here is my directory structure. /user/a /user/b /user/b inside folder a,b,c there is a
I'm having trouble adding Facebook Connect to my iPhone Project. Here's the directory structure:
Here is the directory layout that was installed with Leopard. What is the A
I am planning my directory structure for a linux/apache/php web project like this: Only
My codeigniter application directory structure is like --application --htdocs    --index.php    --.htaccess   
Here is the directory structure of the folder I am trying to archive: DIR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.