1
Fatal error: Smarty error: [in rezultati/index.tpl line 24]: syntax error: $smarty. is an unknown reference (Smarty_Compiler.class.php, line 2164) in D:\HTTPSERVER\wwwroot\kajak\sistem\smarty\libs\Smarty.class.php on line 1093


{assign var="file" value="{$smarty.const.CMS_URL_POT}/moduli/rezultati/files/{$rezultat.datoteka|ss}"}
            {if file_exists($file)}
                <a href="{$file}" target="_blank">{$smarty.const.REZULTATI_025}</a> 
            {/if}

Why this is not valid: {assign var="file" value="{$smarty.const.CMS_URL_POT} and $rezultat.datoteka|ss. |ss is not recogniozed when using assign..

2 Answers 2

2

Use backticks (instead of braces) around the variable:

`$smarty.const.CMS_URL_POT`

From the manual:

Smarty will recognize assigned variables embedded in "double quotes" so long as the variable name contains only numbers, letters, under_scores and brackets[]. See naming for more detail.

With any other characters, for example a .period or $object>reference, then the variable must be surrounded by backticks.

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

5 Comments

Thx i will try. Why to use ` (backticks)?
@senzacionale: That's just how smarty requires it. It's most likely related to PHP's requiring of braces when interpolating multidimensional arrays in a string. I've added a link to the relevant manual page.
thx for help. i also found that in manual. What about $rezultat.datoteka|ss. i can not use |ss and backticks. if using just $rezultat.datoteka then works but if i add |ss then not working any more when using assing.
They show an example: {func var="test ``$foo.bar`` test"|escape}
Whoops. Those should be single backticks in my comment above.
0

Maybe you should try using backticks if you want the constant treated as part of the $smarty variable, take this as an example:

{assign var="myvar" value="20"}
{* myCONST = 'test'  - assuming you have a const defined somewhere *}

{assign var="file" value="(`$smarty.const.myCONST`/moduli/rezultati/files/`$myvar`)"}
{$file} {* should return "test/moduli/rezultati/files/20 *}

Not exactly sure what you want to achieve but I hope this gives you the idea.

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.