问题描述
我安装了SimplePie是一个直线上升的Linux安装程序。 (无字preSS或其它)
我想加我进的文章之间在一面旗帜。举例来说,如果我有10个饲料文章每页显示的,我想5日相继添加一个。
任何帮助很多AP preciated ...我进网页是非常基本的和明显的位置:
如果你不熟悉了SimplePie code,这里基本上是一个非常类似code到什么构成了上面的页面:
要显示我多少文章希望在每一页上,我使用的:
//设置分页我们的价值观
$启动=(使用isset($ _ GET ['开始'])及和放大器;!空($ _ GET ['开始']))? $ _GET ['开始']:0; //我们从哪里开始?
$长度=(使用isset($ _ GET ['长'])及和放大器;!空($ _ GET ['长']))? $ _GET ['长']:10; //每页有多少?
$最大= $馈> get_item_quantity(); //我们在哪里结束?
在你的循环,输出的文章,你可以用一个计数器和模运算符:
$反= 0;
的foreach($馈> get_items($开始,$长度)$关键=> $项){
如果($计数器%5 == 0){//使用模运算符
//展示横幅
}
// ...
$柜台++;
}
请参阅文章。在code上面将显示横幅时$计数器= 0,5,10,等等。
My SimplePie install is a straight-up linux install. (no wordpress or anything)
I'm trying to add a banner in-between my feed articles. For instance if I have 10 feed articles displaying per page, I'd like to add one after the 5th one.
Any help is much appreciated... My feed page is very basic and visible here:
In case you're unfamiliar with SimplePie code, here's basically a very similar code to what makes up the page above:
To display how many articles I want on each page, I use:
// Set our paging values
$start = (isset($_GET['start']) && !empty($_GET['start'])) ? $_GET['start'] : 0; // Where do we start?
$length = (isset($_GET['length']) && !empty($_GET['length'])) ? $_GET['length'] : 10; // How many per page?
$max = $feed->get_item_quantity(); // Where do we end?
In your loop that outputs the articles, you can use a counter and the modulus operator:
$counter = 0;
foreach ($feed->get_items($start, $length) as $key=>$item) {
if ($counter % 5 == 0) { // use modulus operator
// display banner
}
// ...
$counter++;
}
See php modulus in a loop article. The code above will display the banner when $counter = 0, 5, 10, etc.
这篇关于进了SimplePie条款之间添加旗帜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!