2

When using $smarty->fetch, it pulls the template into a variable. Is there way to do pre-parsed string manipulation on that variable?

Example:

PHP:

$variable = $smarty->fetch('template.tpl');
$variable = str_replace("{include file='../another_dir", "{include file='", $variable);

template.tpl

{include file='incl.tpl'}

Ideal result would be to have the template become:

{include file='../another_dir/incl.tpl'}

1 Answer 1

3

You must edit template first. Then you can use fetch.

Something like this:

$template = file_get_contents('template.tpl');
$template = str_replace("{include file='../another_dir", "{include file='", $template);
$variable = $smarty->fetch('string:' . $template);

Smarty String Template Resources.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.