Manos Dilaverakis
Manos Dilaverakis

Reputation: 5879

Templates with identical names and Smarty

I have a small problem with Smarty... I have two different template files in two different directories that happen to have the same name. Unfortunately Smarty gets them confused. It uses the last one to be updated to create a compiled file in its /templates_c folder, which it then uses to display the page.

This means that both files end up looking like the last one to be updated, even thought they're completely different.

I can solve this by renaming one of the files, or presumably calling clear_compiled_tpl. I was wondering, however, if there's a better way. Isn't there a way to configure Smarty to pay attention to the folder a template file is in when creating its compiled files?

Edit: I'm using Smarty v2.6.19

Upvotes: 2

Views: 431

Answers (2)

joe
joe

Reputation: 69

If the files are in the same template_dir but different folders, Smarty should make different compiled files just fine. If you are using more than one template_dir and only one compile_dir, be sure to set a unique $smarty->compile_id for each template folder.

Upvotes: 0

karim79
karim79

Reputation: 342795

Try this before outputting your templates, it's actually an optimization for directories with thousands of template files, but might fix your problem:

$smarty->use_sub_dirs = true;

Upvotes: 3

Related Questions