The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Filter announcements out of newsfeed widget.

3 posters

Go down

Solved Filter announcements out of newsfeed widget.

Post by Mark T April 13th 2014, 8:32 pm

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.


Last edited by Mark T on April 14th 2014, 8:28 am; edited 2 times in total (Reason for editing : stoopid smilies auto inserting...)
avatar
Mark T
New Member

Posts : 5
Reputation : 1
Language : English

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Ange Tuteur April 13th 2014, 11:48 pm

Hello Mark T,

What is the version of your forum ? You'll most likely need only change the selectors in the load function.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Mark T April 13th 2014, 11:56 pm

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.
It's phpBB3.


Changing selectors sounds good... whatever that is... I look forward to some insight!
avatar
Mark T
New Member

Posts : 5
Reputation : 1
Language : English

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Ange Tuteur April 14th 2014, 12:27 am

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.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Mark T April 14th 2014, 8:27 am

Ange 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.
You're a star Very Happy 

Thank's very much, problem solved.

May be worth adding the info to the thread here.
avatar
Mark T
New Member

Posts : 5
Reputation : 1
Language : English

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Jophy April 14th 2014, 10:09 am

Solved
Jophy
Jophy
ForumGuru

Male Posts : 17922
Reputation : 836
Language : English
Location : Somewhere

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum