1
したがって、私は基本的に、現在のURLに基づいて特定のRSSフィードを表示しようとしています。私は以下の解決策にはある程度はあるが、変数にURLを指定するのではなく、現在のURLとif it contains
を確認してRSSフィードを取得する。
複数のURLに対して複数のチェックを行う必要があるため、以下の解決策は機能しません。現在のURL(指定なし)に基づいてif文を作成する
jQuery(function($) { // display rss feed based on current URL
// start conditions to display 3 feeds on different URLs
var url = 'http://localhost:8888/';
if (url.indexOf('8888') > -1) {
$(".feed1").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed2").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed3").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
}
if (url.indexOf('movies') > -1) {
$(".feed1").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed2").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
$(".feed3").rss("http://www.thehollywoodgossip.com/rss.xml",
{
limit: 17,
entryTemplate:'<h1 class="feedtitle"><a href="{url}">[{author}@{date}] {title}</a></h1><br/><div class="featimg">{teaserImage}</div><div class="feedtxt">{shortBodyPlain}</div>'
})
}
.......
フィードURLは異なるであろうことに留意されたいです。これはほんの一例です。
を行い、現在のURLの確認方法については、この疑問ですか? – Reyraa