热搜词
发表于 2016-10-10 10:24:54 | 显示全部楼层 |阅读模式
<{widget id="tenders/fast" title="免费装修设计" from="TSJ"}>
<{widget id="diary/photo" diary_id=$v.diary_id tpl="diary/photo.html"}>
<{widget id="product/filter" cat_id=$pager.cat_id brand_id=$pager.brand_id attr_values=$pager.attr_values order=$pager.order tpl="mall/product/filter.html"}>

<{widget id="tenders/setting" type="way" value=$detail.way_id}>
<{widget id="data/area" value=$shop.area_id city_id=$shop.city_id}>

代码解释:

widget表三调用微件,即一小段代码;
id="tenders/fast" 表示微件文件的路径,tenders/fast表示路径为 /system/plugins/widget/tenders/fast.html;tpl="diary/photo.html" 表示调用的微件文件改为当前模板中的diary/photo.html文件;



全部评论1
灰儿 发表于 2016-10-10 14:08:23 | 显示全部楼层
\system\plugins\widgets\diary\widget.php

<?php
/**
* Copy Right IJH.CC
* Each engineer has a duty to keep the code elegant
* Author @shzhrui<Anhuike@gmail.com>
* $Id: widget.php 2468 2013-12-24 02:04:32Z langzhong $
*/

class Widget_Diary extends Model
{

    public function newitems(&$params){
        $data['cfg_status'] = K::M('home/site')->get_status();
        $params['tpl'] = 'newitems.html';
        return $data;
    }

    public function index(&$params)
    {
                $data['limit'] = $params['limit'] ? $params['limit'] : 5;

        $filter = array('audit'=>1);
        if($params['city_id']){
            $filter['city_id'] = (int)$params['city_id'];
        }

        $diary = K::M('diary/diary')->items($filter,array('diary_id'=>'DESC') , 1,$data['limit']);
        $company_ids = array();
        foreach($diary as $val){
            if(!empty($val['company_id'])) $company_ids[$val['company_id']] = $val['company_id'];
        }
        if(!empty($company_ids)) $data['diary_company_list'] = K::M('company/company')->items_by_ids($company_ids);
        $data['diary'] = $diary;
        $params['tpl'] = 'index.html';
        return $data;

    }

    public function right(&$params){
        $data['limit'] = $params['limit'] ? $params['limit'] : 5;

        $filter = array('audit'=>1);
        if($params['city_id']){
            $filter['city_id'] = (int)$params['city_id'];
        }

        $diary = K::M('diary/diary')->items($filter,array('diary_id'=>'DESC') , 1,$data['limit']);
        $company_ids = array();
        foreach($diary as $val){
            if(!empty($val['company_id'])) $company_ids[$val['company_id']] = $val['company_id'];
        }
        if(!empty($company_ids)) $data['diary_company_list'] = K::M('company/company')->items_by_ids($company_ids);
        $data['diary'] = $diary;
        $params['tpl'] = 'right.html';
        return $data;
    }

}



\system\plugins\widgets\diary\index.html

<{foreach $data.diary as $item}>
    <li>
        <a title="<{$data.diary_company_list[$item.company_id].name|default:'--'}>" class="f14 red" target="_blank" href="<{link ctl='company' arg0=$item.company_id city=$data.diary_company_list[$item.company_id].city_id}>">[<{$data.diary_company_list[$item.company_id].sort_name|default:'--'}>]</a>
        <font class="f14"> | </font>
        <a target="_blank" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id city=$item.city_id}>" title="<{$item.title}>" class="f14 black8"><{$item.title}> </a>
    </li>
<{/foreach}>


\system\plugins\widgets\diary\newitems.html

<p class="mt20 ml20">
    <span class="lt f22">日记分享</span>
    <span class="rt mt10"><a href="<{link ctl='content:diary'}>" class="f12 black">更多>></a></span>
</p>
<div class="cl"></div>
<div class="rijifenxaing_l_ul">
    <ul>
        <{foreach from=$data.cfg_status item=item key=key name=loop}>
        <{if $smarty.foreach.loop.index < 6}>
        <li> <a target="_blank" href="<{link ctl='content:diary' arg0=$key}>"><{$item}></a></li>
        <{/if}>
        <{/foreach}>  
    </ul>
</div>
<div class="cl"></div>
<div class="rijifenxiang_content hauto mt10">
    <{calldata mdl="diary/diary" order="pv_num:desc" limit="3"}>
    <a title="<{$item.title}>"  target="_blank" style="float: left; margin-right: 10px;" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>"><img src="<{$pager.img}>/<{$item.face_pic}>" width="140" height="85"/></a>
    <{/calldata}>
    <div class="cl"></div>
    <p class="h10 bodr_b"></p>
    <div class="rijifenxiang_content_ul hauto">
        <ul>
            <{calldata mdl="diary/diary" order="diary_id:desc" limit="5"}>
            <li><font>[<{$data.cfg_status[$item.status]}>]</font><a target="_blank" title="<{$item.title}>" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>"><{$item.title}></a></li>
            <{/calldata}>   
        </ul>
    </div>
</div>
<div class="cl"></div>
<div class="h10"></div>


\system\plugins\widgets\diary\right.html

<ul>
<{foreach $data.diary as $item}>
    <li>
        <a title="<{$data.diary_company_list[$item.company_id].name|default:'--'}>" class="red" target="_blank" href="<{link ctl='company' arg0=$item.company_id}>">[<{$data.diary_company_list[$item.company_id].sort_name|default:'--'}>]</a>
        <a target="_blank" href="<{link ctl='content:diaryDetail' arg0=$item.diary_id}>" title="<{$item.title}>" class="black"><{$item.title|cutstr:24:'..'}> </a>
    </li>
<{/foreach}>
</ul>


\themes\default\diary\photo.html

<dl class="diary_items_photo">
<{foreach $data.photo as $item name=foo}>
        <{if $smarty.foreach.foo.index == 0}>
    <dt><a  target="_blank" href="<{link ctl='diary:detail' arg0=$item.diary_id}>" rel="nofollow" ><img src="<{$pager.img}><{$item}>"> <a class="total">共<{$data.count}>张</a> </a></dt>
    <{else if $smarty.foreach.foo.index <=3}>
    <dt><a  target="_blank" href="<{link ctl='diary:detail' arg0=$item.diary_id}>" rel="nofollow" ><img src="<{$pager.img}><{$item}>"> </a></dt>
    <{/if}>
<{/foreach}>
</dl>
<p class="graycl"> <{if !$data.dateline}>暂时还没有日记<{else}><{$data.dateline|format}>前被回复<{/if}> </p>

回复

使用道具 举报

回复
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|管理员之家 ( 苏ICP备2023053177号-2 )

GMT+8, 2024-12-29 18:11 , Processed in 0.155300 second(s), 22 queries .

Powered by Discuz! X3.5

Cpoyright © 2001-2024 Discuz! Team