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

  • Home
  • SEARCH
  • 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 296389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:32:39+00:00 2026-05-12T06:32:39+00:00

for our latest project we used Django, where one can specify a list of

  • 0

for our latest project we used Django, where one can specify a list of folders, that are searched for a template, say, with name example.html. Now, we switched back to Smarty (PHP) and are wondering, if there is something similar.

Smarty version: Can be cutting-edge.

Behaviour:

  1. Feed Smarty with an array of folders.
  2. Call a template either with $smarty->display() or {include}.
  3. Smarty searches through the folders and takes the first template matching the name.

I looked at Smarty resources, but they look like overkill for this task, and the docs are a bit sparse on this topic. Any ideas how this could be done?

An additional problem is, that the list of folders may change depending on the requested URL. Any ideas how to tell Smarty, which compiled template to use?

Cheers,

  • 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-12T06:32:40+00:00Added an answer on May 12, 2026 at 6:32 am

    In Smarty.class.php, in the method Smarty::_parse_resource_name() :

    foreach ((array)$params['resource_base_path'] as $_curr_path) {
        $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
        if (file_exists($_fullpath) && is_file($_fullpath)) {
            $params['resource_name'] = $_fullpath;
            return true;
        }
        // didn't find the file, try include_path
        $_params = array('file_path' => $_fullpath);
        require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
        if(smarty_core_get_include_path($_params, $this)) {
            $params['resource_name'] = $_params['new_file_path'];
            return true;
        }
    }
    

    $params['resource_base_path'] is defaulted to $this->template_dir in Smarty::_fetch_resource_info().

    So it looks like you can set $smarty->template_dir to an array of directories to look in. Note that this won’t be recursive. This must be an undocumented feature.

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

Sidebar

Related Questions

I've taken the plunge and used Guice for my latest project. Overall impressions are
Our team is creating a new recruitment workflow system to replace an old one.
Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding
Our dev shop currently uses Visual SourceSafe. We all know how that could end
I am working with a tester who is using Selenium in my latest project.
I have a project that comprises pre-build Dll modules, built some time in the
Our project is a content management system supporting several dozen of our websites. The
Our project has a dependency like <dependency> <groupId>apollo.components.cots</groupId> <artifactId>cots-wfs</artifactId> </dependency> And as far as
Our product is installed in Windows machines all over the world, with our latest
Our company is currently writing a GUI automation testing tool for compact framework applications.

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.