Filter announcements out of newsfeed widget.
3 posters
Page 1 of 1
Filter announcements out of newsfeed widget.
This is probably a simply Jscript question... but i don't know Jscript and am just hacking about using code very usefully posted on this site...
I'm trying to create a news feed widget for specified forums but want to ignore the announcements as they appear in every forum. So far i have:
jQuery("#newsareal1").load("/f28-dig-finds div.topic-title-container:lt( 8 )");
... so it selects the first eight posts from the dig finds forum... but the first ones are always the announcements!
I can change :lt( 8 ) to be :gt(3):lt(11); so it skips the first 3 and shows the next 8 but i would have to change the code every time the number of announcements changed... so not a realistic option.
I think i can add a .filter() before the .load but I don't know what to put in it... or if this is the right thing to do (should i add a :not() after the :lt() instead for instance?).
For completeness:
The widget for the portal contains:
<h3>Dig Finds</h3>
<div id="newsareal1" class="newsareal"></div>
<h3>Rally Finds</h3>
<div id="newsareal2" class="newsareal"></div>
<h3>Finds ID</h3>
<div id="newsareal3" class="newsareal"></div>
The javascript currently has:
jQuery(document).ready(function(){
jQuery("#newsareal1").load("/f28-dig-finds div.topic-title-container:lt( 8 )");
jQuery("#newsareal2").load("/f27-rally-finds div.topic-title-container:lt( 8 )");
jQuery("#newsareal3").load("/f7-id-your-finds-with-mick-paul- div.topic-title-container:lt( 8 )");
});
Thanks for your help.
I'm trying to create a news feed widget for specified forums but want to ignore the announcements as they appear in every forum. So far i have:
jQuery("#newsareal1").load("/f28-dig-finds div.topic-title-container:lt( 8 )");
... so it selects the first eight posts from the dig finds forum... but the first ones are always the announcements!
I can change :lt( 8 ) to be :gt(3):lt(11); so it skips the first 3 and shows the next 8 but i would have to change the code every time the number of announcements changed... so not a realistic option.
I think i can add a .filter() before the .load but I don't know what to put in it... or if this is the right thing to do (should i add a :not() after the :lt() instead for instance?).
For completeness:
The widget for the portal contains:
<h3>Dig Finds</h3>
<div id="newsareal1" class="newsareal"></div>
<h3>Rally Finds</h3>
<div id="newsareal2" class="newsareal"></div>
<h3>Finds ID</h3>
<div id="newsareal3" class="newsareal"></div>
The javascript currently has:
jQuery(document).ready(function(){
jQuery("#newsareal1").load("/f28-dig-finds div.topic-title-container:lt( 8 )");
jQuery("#newsareal2").load("/f27-rally-finds div.topic-title-container:lt( 8 )");
jQuery("#newsareal3").load("/f7-id-your-finds-with-mick-paul- div.topic-title-container:lt( 8 )");
});
Thanks for your help.
Last edited by Mark T on April 14th 2014, 8:28 am; edited 2 times in total (Reason for editing : stoopid smilies auto inserting...)
Mark T- New Member
- Posts : 5
Reputation : 1
Language : English
Re: Filter announcements out of newsfeed widget.
Hello Mark T,
What is the version of your forum ? You'll most likely need only change the selectors in the load function.
What is the version of your forum ? You'll most likely need only change the selectors in the load function.
Re: Filter announcements out of newsfeed widget.
It's phpBB3.Ange Tuteur wrote:Hello Mark T,
What is the version of your forum ? You'll most likely need only change the selectors in the load function.
Changing selectors sounds good... whatever that is... I look forward to some insight!
Mark T- New Member
- Posts : 5
Reputation : 1
Language : English
Re: Filter announcements out of newsfeed widget.
Okay first make sure that the announcements are in a separate table :
Administration panel > general > messages and e-mails > configuration
Find 'Separate announcements and stickies from the messages', set it to 'with a table', and save.
Then add '.forumbg:not(.announcement)' before 'div.topic-title-container', it should look like :
That should only select topics that are not inside the announcement table.
Administration panel > general > messages and e-mails > configuration
Find 'Separate announcements and stickies from the messages', set it to 'with a table', and save.
Then add '.forumbg:not(.announcement)' before 'div.topic-title-container', it should look like :
- Code:
jQuery("#newsareal1").load("/f1-the-health-of-your-cat .forumbg:not(.announcement) div.topic-title-container:lt(11)");
That should only select topics that are not inside the announcement table.
Re: Filter announcements out of newsfeed widget.
You're a starAnge Tuteur wrote:Okay first make sure that the announcements are in a separate table :
Administration panel > general > messages and e-mails > configuration
Find 'Separate announcements and stickies from the messages', set it to 'with a table', and save.
Then add '.forumbg:not(.announcement)' before 'div.topic-title-container', it should look like :
- Code:
jQuery("#newsareal1").load("/f1-the-health-of-your-cat .forumbg:not(.announcement) div.topic-title-container:lt(11)");
That should only select topics that are not inside the announcement table.
Thank's very much, problem solved.
May be worth adding the info to the thread here.
Mark T- New Member
- Posts : 5
Reputation : 1
Language : English
Jophy- ForumGuru
- Posts : 17922
Reputation : 836
Language : English
Location : Somewhere
Similar topics
» Filter "new post" results
» Post requirement to use Chatbox (Filter by Usergroups)
» double posting problem/spam filter?
» Scaling Widget Background Image Based on Widget Size/User Resolution
» How to do this Advanced Hiding Widget Code as well as the Recent Topic's Widget Modification
» Post requirement to use Chatbox (Filter by Usergroups)
» double posting problem/spam filter?
» Scaling Widget Background Image Based on Widget Size/User Resolution
» How to do this Advanced Hiding Widget Code as well as the Recent Topic's Widget Modification
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum