smarty摸板能对付floor这样的算法吗??

eingmarra 2006-07-29 02:49:31
{section name=customer loop=$page.last_page_of_all+1 start=Math.floor($page.current_page/10) max=$page.last_page_of_all}

其中math.floor($page.current_page/10)会报错的!求解?!
...全文
248 9 打赏 收藏 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
yibotiemen 2006-08-02
  • 打赏
  • 举报
回复
同意alasika(堕落人间) 的做法,注册一个modifier就可以了,很方便
xuzuning 2006-08-02
  • 打赏
  • 举报
回复
由 {math equation="x + y" x=$height y=$width}
可得 {math equation="floor(x / y)" x=$height y=$width}
ten789 2006-08-02
  • 打赏
  • 举报
回复
为什么要有模板呢 就是为了从<a herf="<?echo $a?>"><?echo $b?></a>这类PHP和HTML混合在一起的代码能够分离也就是内容与表现分离
PHP负责内容 如从根据请求从数据库取得内容
HTML负责表现 也就是把PHP生成的内容表现出来 颜色 布局等等

试想PHP和HTML是两个人分开来写 写PHP的人怎么告诉写HTML的人呢
{section name=customer loop=$page.last_page_of_all+1 start=Math.floor($page.current_page/10) max=$page.last_page_of_all}
这样的方式显然是不合适的
$news = array(0=>array('title'=>'','date'=>''));这里是新闻的内容
在建立好开发规范以后 直接写明$news是内容 有title,date等字段就可以了
另外附加 页面信息$page 里面包含 开始的变量 结束的变量等等

具体怎么表现那就是写HTML的人要考虑的 3列显示 等等

再回来看楼主的问题 试想SMARTY替换后的代码是什么
fro($section.customer.index=Math.floor($page.current_page/10);$secion.customer.index<=$page.last_page_of_all;$secion.customer.index++) 谁会给自己写这样的代码看?
让PHP和SMARTY做各自该做的事
alasika 2006-08-01
  • 打赏
  • 举报
回复
写smarty plugin应该是比较好的方法吧
如
{$page.current_page/10|floor}
eingmarra 2006-07-31
  • 打赏
  • 举报
回复
楼上,我不太懂你的意思,"PHP和HTML分离 这样的做法是错误的"--我觉得你的观点本身就是错误的!
ten789 2006-07-31
  • 打赏
  • 举报
回复
PHP和HTML分离 这样的做法是错误的 写HTML的人不知道从何开始到哪结束 他们只管显示一个数组显示哪些字段 怎么显示出来 如果行数是不定的 应该单独给出变量
eingmarra 2006-07-31
  • 打赏
  • 举报
回复
谢谢楼上的老大!
{math equation="x + y" x=$height y=$width}

smarty的手册里看到的,但还是不符合我的要求.只能在smarty以外的php文件里写吗?不知道还有没有更好的方法...
helloyou0 2006-07-30
  • 打赏
  • 举报
回复
smarty里没办法,除非改它的程序
从外面assign进来
eingmarra 2006-07-30
  • 打赏
  • 举报
回复
顶一下

21,889

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧