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 8368637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:26:08+00:00 2026-06-09T13:26:08+00:00

I am not quite sure about this, but reading from the smarty instructions http://www.smarty.net/docs/en/installing.smarty.basic.tpl

  • 0

I am not quite sure about this, but reading from the smarty instructions http://www.smarty.net/docs/en/installing.smarty.basic.tpl , I would have to set $template_dir, $compile_dir, $config_dir, and $cache_dir every time I have a new PHP script. In other words, I would have to add the following lines of code for each PHP script:

$smarty->setTemplateDir('/.../templates/');
$smarty->setCompileDir('/...templates_c/');
$smarty->setConfigDir('/.../configs/');
$smarty->setCacheDir('/.../cache/');

Is that correct? Did you guys do any “shortcuts” to avoid this?

  • 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-06-09T13:26:09+00:00Added an answer on June 9, 2026 at 1:26 pm

    You should set all of these things in a common config file, then include it when you need it.

    include( 'path/to/common_config.php' );
    

    Then, in your common_config.php, you can just do something like this:

    //set up Smarty
    require_once( dirname( __FILE__ ) . '/smarty/Smarty.class.php' );
    $smarty = new Smarty;
    $smarty->error_reporting = E_ALL & ~E_NOTICE;
    $smarty->setTemplateDir( dirname( __FILE__ ) . '/../templates' );
    $smarty->setCompileDir( dirname( __FILE__ ) . '/../smarty/templates_c' );
    

    The use of “dirname( FILE )” will ensure that the path is always relative to the common config file.

    Now all you need to do is use the display method with the name of the template file:

    $smarty->display( 'index.tpl' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spent hours reading up about AppDomains, but I'm not sure they work quite
Ok, I'm not quite sure how to go about this. Here's the scenario. 1)
I'm not quite sure how to go about styling this particular bit of php:
I'm not quite sure about this in the standards. Say I have three files
Sorry for the vague title, but not quite sure how to summarize this one.
I've been thinking about this problem for a while, and not quite sure the
Ok, a few things I'm not quite sure about. For starters: I have a
Not quite sure how to go about describing what it is I'm trying to
I'm not quite sure if it's possible to do what I'm about to ask
I'm a little confused about render, not quite sure which path it chooses to

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.