{assign var开发者_Python百科=tmp_url value=setURI(array('page' => 1))}
It seems array()
can't be used in smarty ?
I tried various ways ,but none work.
Anyone knows the trick?
try this,
In php file, write a function
<?php
function getSetUri(){
return setURI(array('page' => 1));
}
?>
In template file, just call the function
{assign var=tmp_url value=getSetUri()}
as far as I can tell there is no native way of setting an array in smarty you could assign the array to smarty templete in your php and call it page
then accesss it in smarty like this
{assign var=tmp_url value=setURI($page[1])}
or you could use a plug in. there are some other options in this thread but I'm not sure what will be best for you. you may need to find another way of doing what you want or modifying your function in some way so it can take a string
You could use {php}
tags to assign the variable value in there:
<h1>Foo!{$var}</h1>
{php}
$this->assign('tmp_url', setURI($page[1]));
{/php}
<a href={$tmp_url}">bar</a>
精彩评论