Blogger Information
Blog 25
fans 0
comment 0
visits 29647
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
织梦CMS调用子栏目时没有子栏目不显示
宿州市筋斗云信息科技-Vip
Original
2430 people have browsed it

织梦CMS调用子栏目时没有子栏目不显示

HTML页面调用标签

{dede:channelartlist}
    <dl>
    <!--二级栏目-->
	<dt class="nav-title">
	<a href="{dede:field name='typeurl'/}" style="color:#fff;">{dede:field name='typename'/}</a> 
	</dt>
	 <!--三级栏目-->				
	{dede:channel type='son' noself='yes' }
	<dd>
	<a href="[field:typelink/]">[field:typename/]</a>
	</dd>
	{/dede:channel}
    </dl>	
{/dede:channelartlist}

修改织梦文件

打开:include\taglib\channel.lib.php文件。找到下面的代码

 $needRel = false;
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field','[',']');
    $dtp2->LoadSource($innertext);
    //检查是否有子栏目,并返回rel提示(用于二级菜单)
    if(preg_match('#:rel#', $innertext)) $needRel = true;
    
    if(empty($sql)) return '';
    $dsql->SetQuery($sql);
    $dsql->Execute();
    
    $totalRow = $dsql->GetTotalRow();
    //如果用子栏目模式,当没有子栏目时显示同级栏目
    //===================================================修改这里================================
    if($type=='son' && $reid!=0 && $totalRow==0 )
    //===============================================================================================
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
            FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
        $dsql->SetQuery($sql);
      $dsql->Execute();
    }
    $GLOBALS['autoindex'] = 0;

修改成

 $needRel = false;
    $dtp2 = new DedeTagParse();
    $dtp2->SetNameSpace('field','[',']');
    $dtp2->LoadSource($innertext);
    //检查是否有子栏目,并返回rel提示(用于二级菜单)
    if(preg_match('#:rel#', $innertext)) $needRel = true;
    
    if(empty($sql)) return '';
    $dsql->SetQuery($sql);
    $dsql->Execute();
    
    $totalRow = $dsql->GetTotalRow();
    //如果用子栏目模式,当没有子栏目时显示同级栏目
    //==========================================多添加一个&& $noself=='' 条件
    if($type=='son' && $reid!=0 && $totalRow==0 && $noself=='')
    {
        $sql = "SELECT id,typename,typedir,isdefault,ispart,defaultname,namerule2,moresite,siteurl,sitepath
            FROM `#@__arctype` WHERE reid='$reid' And ishidden<>1 order by sortrank asc limit 0, $line ";
        $dsql->SetQuery($sql);
      $dsql->Execute();
    }
    $GLOBALS['autoindex'] = 0;


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post