添加外部链接步骤

讨论
已结 精华
3 618
kaersaide
kaersaide 2018-08-16

第一步:在 category 数据表新增外链字段  例如 “waibu”   varchar 255 就行

第二步:在application/admin/view/category目录下的add.html 和edit.html 增加如下代码(add.html 去掉input元素的value值):

<div class="layui-form-item">
    <label class="layui-form-label">外部链接</label>
    <div class="layui-input-block">
        <input type="text" name="waibu" value="{$record.waibu}" placeholder="{:lang('pleaseEnter')}外部链接" class="layui-input">
    </div>
</div>

第三步:修改前端导航代码

<ul id="menu">
    <li {if condition="$controller eq 'index'"}class="selected"{/if}><a href="{:url('home/index/index')}" title="CLTPHP内容管理系统">首页</a></li>
    {volist name="category" id="vo"}
    <li {if condition="$controller eq $vo['catdir']"}class="selected"{/if}>
        {if condition="$vo['child'] eq 1"} 
        <a href="#">{$vo.catname}</a>   
        <ul>
            {volist name="$vo.sub" id="v"}
            {if condition="$v['waibu'] neq '' "} 
            <li><a href="{$v.waibu}" title="{$v.catname}-CLTPHP内容管理系统"  target="_blank"><span>-</span> {$v.catname}</a></li>
            {else/}
            <li><a href="{:url('home/'.$vo['catdir'].'/index',['catId'=>$v['id']] )}" title="{$v.catname}-CLTPHP内容管理系统"><span>-</span> {$v.catname}</a></li>
            {/if} 
            {/volist}
        </ul> 
        {else /}
        {if condition="$vo['waibu'] neq '' "} 
        <a href="{$vo.waibu} " title="{$vo.catname}-CLTPHP内容管理系统" target="_blank">{$vo.catname}</a>
        {else/}
        <a href="{:url('home/'.$vo['catdir'].'/index',['catId'=>$vo['id']] )}" title="{$vo.catname}-CLTPHP内容管理系统">{$vo.catname}</a>
        {/if}  
        {/if}
    </li>
    {/volist}
</ul>

上一篇:cltphp5.6.6版本安装教程-宝塔练手

下一篇:招募CLTPHP.Pro内测成员(已结束)

回帖
  • 2018-08-16 17:51:59

    注意  在admin 模块   view文件夹下的 category文件夹  有add.html  和edit.html都要加上


    0 回复
  • 2018-08-16 17:56:31

    完整代码  

     <ul id="menu">

                    <li {if condition="$controller eq 'index'"}class="selected"{/if}><a href="{:url('home/index/index')}" title="CLTPHP内容管理系统">首页</a></li>

                    {volist name="category" id="vo"}

                        <li {if condition="$controller eq $vo['catdir']"}class="selected"{/if}>

                            {if condition="$vo['child'] eq 1"} 

                         <a href="#">{$vo.catname}</a>   

                                            <ul>

                                                {volist name="$vo.sub" id="v"}

                                                    {if condition="$v['waibu'] neq '' "} 

                                                        <!--建议加新窗口打开,认证把thinkphp的文档看一遍 ,谢谢老大我复一下您写的-->

                                                         <li><a href="{$v.waibu}" title="{$v.catname}-CLTPHP内容管理系统"  target="_blank"><span>-</span> {$v.catname}</a></li>

                                                    {else/}

                                                        <li><a href="{:url('home/'.$vo['catdir'].'/index',['catId'=>$v['id']] )}" title="{$v.catname}-CLTPHP内容管理系统"><span>-</span> {$v.catname}</a></li>

                                                    {/if} 

                                                {/volist}

                                            </ul> 

                             {else /}

                                      {if condition="$vo['waibu'] neq '' "} 

                            <!--建议加新窗口打开-->

                                       <a href="{$vo.waibu} " title="{$vo.catname}-CLTPHP内容管理系统" target="_blank">{$vo.catname}</a>

                                  {else/}

                                      <a href="{:url('home/'.$vo['catdir'].'/index',['catId'=>$vo['id']] )}" title="{$vo.catname}-CLTPHP内容管理系统">{$vo.catname}</a>

                                   {/if}  

                   

                                  {/if}

                   </li>

                    {/volist}

                </ul>


    0 回复
取消评论