The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Filter announcements out of newsfeed widget.

View previous topic View next topic Go down

Solved Filter announcements out of newsfeed widget.

Post by Mark T on 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...)

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 on 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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Mark T on 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'sphpBB3.


Changing selectors sounds good... whatever that is... I look forward to some insight!

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 on 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
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Filter announcements out of newsfeed widget.

Post by Mark T on 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 threadhere.

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 on April 14th 2014, 10:09 am

Solved

Jophy
ForumGuru

Male Posts : 17924
Reputation : 835
Language : English
Location : Somewhere

Back to top Go down

View previous topic View next topic Back to top


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