灵动标签调用相关链接,怎么才能在调不到或者数量不足的情况下 调用其它的啊?比如我们下面的代码
A:加个计数器来判断
- <div class="l_item rel_art mt">
- <div class="tit">
- <h3>相关新闻</h3>
- </div>
- <ul>
- [e:loop={'news',8,18,1,"related = '$navinfor[title]'"}]
- <li><a href="<?=$bqsr['titleurl']?>" title="<?=$bqr['title']?>"><img src="<?=$bqr['titlepic']?>" alt="<?=$bqr['title']?>"><span><?=$bqr['title']?></span></a></li>
- [/e:loop]
- </ul>
- </div>
B:其实计数器是没有必要另外添加的。$bqno变量直接使用就可以。
- <?php
- //计数器
- $tn = 0;
- ?>
- [e:loop={'news',8,18,1,"related = '$navinfor[title]'"}]
- <?php
- $tn += 1;
- ?>
- <li><a href="<?=$bqsr['titleurl']?>" title="<?=$bqr['title']?>"><img src="<?=$bqr['titlepic']?>" alt="<?=$bqr['title']?>"><span><?=$bqr['title']?></span></a></li>
- [/e:loop]
- <?php
- if($tn<10){
- $limit = $10- $tn;
- ?>
- [e:loop={0,$limit,3,0}]
- <a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
- [/e:loop]
- <?php
- }
- ?>
- [e:loop={'news',8,18,1,"related = '$navinfor[title]'"}]
- <li><a href="<?=$bqsr['titleurl']?>" title="<?=$bqr['title']?>"><img src="<?=$bqr['titlepic']?>" alt="<?=$bqr['title']?>"><span><?=$bqr['title']?></span></a></li>
- [/e:loop]
- <?php
- if($bqno<10){
- $limit = $10- $bqno;
- ?>
- [e:loop={0,$limit,3,0}]
- <a href="<?=$bqsr['titleurl']?>" target="_blank"><?=$bqr['title']?></a> <br>
- [/e:loop]
- <?php
- }
- ?>