1. 文字拼接,文字查找,计数,截取
12 {assign var="comp" value=""} 3 {assign var="count" value="0"} 4 {utilCall fn="utilGetCalendarTimeSlice" rn="calendar" cat_id="43" start_date=$start_date end_date=$end_date culture="en" limit="" sort_by="startDate"} 5 {if $calendar} 67 {foreach from=$calendar item=curr_item name=curr_item} 8 {foreach from=$curr_item item=event name=event} 9 {assign var="c" value=$event.id|cat:','}10 {if $comp|strpos:$c === false} //文字查找11 {assign var="comp" value=$comp|cat:$event.id|cat:','} //文字拼接12 {assign var="count" value=$count+1} //计数13 {/if}14 {if $count <= 10} //获取Top 1015
23 {/if}24- 16 {$event.title|truncate:60:'...'}//文字截取17 {$event.start_date|date_format:"%B %e, %Y"}-{$event.end_date|date_format:"%B %e, %Y"}18
19 {/if}20 {/foreach}21 {/foreach}22
2. 分页
12 First //第一页 3 {if $pagerInfo.currentPage > 1} //如果当前页大于1,则有pre链接 4 Pre 5 {else} 6 Pre 7 {/if} 8 {section name=forpage loop=$pagerInfo.pageCount} //loop循环总数 9 {assign var="pindex" value=$smarty.section.forpage.index+1} //index从0开始计数10 {$pindex}11 {/section}12 {if $pagerInfo.currentPage < $pagerInfo.pageCount}//如果当前页小于总页数,则有next链接13 Next14 {else}15 Next16 {/if}17 Last18
3. 随机排序显示Page中的mediaObject
1 {utilCall fn="utilGetPageById" rn="sliders" Id='156223'} //获取page 2319 {literal}20 57 {/literal}4 5 {if $sliders->mediaObjects} 6187 {assign var="img" value=""} 8 {assign var="title" value=""} 9 {foreach from=$sliders->mediaObjects item=slider} //获取所有mediaObjects10 {assign var="img" value=$img|cat:$slider->getHumanReadbleURL('')|cat:','}11 //把mediaObject的url地址用逗号分割放入img 字符串12 {assign var="title" value=$title|cat:$slider->title|cat:','} 13 //把mediaObject的title用逗号分割放入title字符串14 {/foreach}15
16 {/if}17