搜索页

因为时间关系,暂时只列举出一些常用标签

YzmCMS V5.8版本新增全站搜索,即表单modelid的值可以等于0

搜索表单
<form method="get" action="{U('search/index/init')}" target="_blank">
    <div id="searchtxt" class="searchtxt">
        <div class="searchmenu">    
            <div class="searchselected" id="searchselected">全站</div>    
            <div class="searchtab" id="searchtab">
                <ul>
                    <li data="0">全站</li>
                    <li data="1">文章</li>
                    <li data="2">产品</li>
                    <li data="3">下载</li>
                </ul>
            </div>
        </div>
        <input type="hidden" name="modelid" value="0" id="modelid" />
        <input name="q" type="text" placeholder="输入关键字"/>
    </div>
    <div class="searchbtn">
        <button id="searchbtn" type="submit">搜索</button>
    </div>
</form>
页面中记得引入公共JS文件
<script type="text/javascript" src="{STATIC_URL}js/yzm-front.js"></script>
YzmCMS v6.3 新增搜索标签,旧版本请自行升级,以下代码为V6.3版本代码,使用前请注意系统版本!
搜索结果页(search.html)
{m:search field="id,catid,title,updatetime,thumb,url,color,flag,description" keyword="$q" siteid="$siteid" modelid="$modelid" limit="10" page="page"}
<div class="yzm-title">
    <h2>“{$q}” 的搜索结果,共{php echo $tag->total}条</h2>
</div>
{loop $data $v}
{php $v['color_title'] = str_ireplace($q, "<span style='color:red;'>$q</span>", $v['title']);}
{php $v['description'] = str_ireplace($q, "<span style='color:red;'>$q</span>", $v['description']);}
<div class="yzm-news">
    <a href="{$v[url]}" class="yzm-news-img">
        <img src="{get_thumb($v['thumb'])}" alt="{$v[title]}" title="{$v[title]}" />
    </a>
    <div class="yzm-news-right">
        {if strstr($v['flag'],'1')}<em>顶</em>{/if}
        <!-- 内容属性 -->
        <a href="{$v[url]}">{$v[color_title]}</a>
        <p>{$v[description]}</p>
        <div class="yzm-news-tags">
            {php $tag_data = content_list_tag($v['catid'], $v['id']);}
            {loop $tag_data $val}
            <a href="{tag_url($val['id'])}" target="_blank">{$val[tag]}</a>
            {/loop}
        </div>
    </div>
</div>
{/loop}
<div id="page">{$pages}</div>