织梦导航循环指定栏目出现 rel="nofollow"的方法
织梦导航循环指定栏目出现 rel="nofollow"代码如下
{dede:channel type='top' row='8'}
<a href="[field:typelink/]" [field:id runphp=yes]
if(@me == 1){
@me = 'rel="nofollow"';
}else if(@me == 9){
@me = 'rel="nofollow"';
}else if(@me == 5){
@me = 'rel="nofollow"';
}else if(@me == 8){
@me = 'rel="nofollow" ';
}else if(@me == 7){
@me = 'rel="nofollow"';
}else{@me = '';}
[/field:id] >[field:typename/]</a>
{/dede:channel}
代码说明
if(@me == 9){ @me = 'rel="nofollow")
//如果id等于9就会输出rel="nofollow"
// 如果想让指定id输出rel="nofollow" 就是添加,反之就不添加
另外一种,使用方法就是使用织梦自定义函数,写在include/extend.func.php里
function is_nofollow($id){
switch ($id) {
case '1':
$nofollow = 'rel="nofollow"';
break;
case '2':
$nofollow = 'rel="nofollow"';
break;
case '3':
$nofollow = 'rel="nofollow"';
break;
case '4':
$nofollow = 'rel="nofollow"';
break;
default:
$nofollow = '';
break;
}
return $nofollow;
}
织梦调用方法如下
{dede:channel type='top' row='8'} <a href="[field:typelink/]" [field:id function="is_nofollow(@me)"/]>[field:typename/]</a> {/dede:channel}