user1222589
user1222589

Reputation: 87

find template files in 'default' directory when it don't exist in current template directory

I have two smarty temlates in my website,'default' and 'w3g',each of them in it's own directory,'/smarty/templates/default' and '/smarty/templates/w3g'

'w3g' is new template for mobile agent,it contains most of page.

but if i visit a page do'not contain a 'w3g' template(for example:http://www.mydomain.com/gifts.php),it will thown an exception like:

"Uncaught exception 'SmartyException' with message 'Unable to load template file 'gifts_index.tpl'...."

but 'default' has 'gifts_index.tpl'

so ,i want the smarty do this: when parse template,if it can't find template file in it's current template directory( 'w3g' ),it will try to find in directory of 'default' and render the result,if it can't find in the two directory, then thown the exception

how can i do?or can i write a plugin to smarty?thanks

Upvotes: 0

Views: 184

Answers (1)

David
David

Reputation: 253

I do not use smarty, but the php way of doing this would be

( file_exists ('file name') ) ? <code for current directory> : <code for default directory>; 

Upvotes: 1

Related Questions