0

I want to know how to write php syntax in smarty template(.tpl).

For example I'm using below php syntax in Pure Codeigniter(No Smarty include) and it's working perfectly.

<?= isset($value) ? $value['phone'] : '' ?>

But in Smarty, It's not work. How should write this? Please suggest me.

Kyaw Zin Wai
  • 449
  • 5
  • 10
  • 26

2 Answers2

2

Try this:

{if isset($value)}
    $value['phone']
{/if}
Arkadiusz G.
  • 1,024
  • 10
  • 24
1

years ago I used:

{php}
// php code
{/php}

Nowadays I don't know if it still works

ZiTAL
  • 3,466
  • 8
  • 35
  • 50
  • 1
    Thanks alot bro. But In smarty 3 It's not working. I already tested it. Anyway thanks u for your answer. For now I can do it as #Arkadiusz G Said. {if isset($value)} $value['phone'] {/if} This condition is working for me now. – Kyaw Zin Wai Feb 06 '17 at 08:54
  • maybe this can help: http://stackoverflow.com/a/30262065/454827 @KyawZinWai – ZiTAL Feb 06 '17 at 09:19