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.

Portal NEWS widget - show the last message

View previous topic View next topic Go down

Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 6:10 pm

Technical Details


Forum version : #phpBB2
Position : Founder
Concerned browser(s) : Google Chrome
Who the problem concerns : Yourself
Forum link : ( link is hidden, you must reply to see )

Description of problem

Hey guys!

I was looking into making a proper news widget to feature the news topic. So it should show the latest message in the topic.

The already suggested by Forumotions widget "NEWS" unfortunately only shows the first message of the topic. (even if the topic has Sort the posts of a topic by : by post date most recent first enabled) any idea if this can be changed?

Also, NEWS widget specifies only selected forum, you cannot choose to always show one selected topic.

Is it possible to show the last message of the selected topic using a script then? Would this work with NEWS widget or a separate widget will have to be created?
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Justice™ on August 9th 2017, 6:21 pm

Hi,

So you have a topic and you want to show to last post in it in a widget, right? If so, then it's possible and actually pretty easy to do. Let me know if that's what you want.
avatar
Justice™
Forumember

Posts : 521
Reputation : 121
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 6:24 pm

Yes, exactly that.

Haha, apologies for my convoluted explanation.
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Justice™ on August 9th 2017, 6:28 pm

PM me an account on your forum(member, not mod or anything else).
avatar
Justice™
Forumember

Posts : 521
Reputation : 121
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 6:30 pm

Sent. Let me know if you will get lost or don't understand something Wink
Page translate should help, tho.
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Justice™ on August 9th 2017, 6:49 pm

Add this script with placement on all pages:
Code:
$(function(){
var forum=3587;
var elem=$(".news_forum");
if(!elem.length) return;
$.get("/t"+forum+"-?view=newest", function(data){
data=$(".postbodyinside", data).last().html();
elem.html(data);
})
})
You have to edit this:
Code:
var forum=3587;
3587 is the topic id.
Place this HTML code where you want the post to load:
Code:
<div class="news_forum">Loading...</div>
You can modify it how you want as long as it has the class news_forum.
avatar
Justice™
Forumember

Posts : 521
Reputation : 121
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 7:03 pm

The topic ID would be for example: 153567? (this topic)
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Justice™ on August 9th 2017, 7:03 pm

Yup.
avatar
Justice™
Forumember

Posts : 521
Reputation : 121
Language : Romanian and English

http://board.realmsn.com

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 7:12 pm

Oh wow. Amazing!

Had to put it in
Code:
$(document).ready(function(){
tho.
One more thing, how to get the posters name? If possible.
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by SLGray on August 9th 2017, 8:01 pm

Do you mean the author of the post?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

avatar
SLGray
Administrator
Administrator

Male Posts : 41111
Reputation : 2808
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by Kami-sama on August 9th 2017, 8:03 pm

Yes. Not the topic author, but the referred post author.
avatar
Kami-sama
Forumember

Female Posts : 329
Reputation : 9
Language : English, Russian, German, Lithuanian
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Re: Portal NEWS widget - show the last message

Post by _Twisted_Mods_ on August 21st 2017, 3:56 pm

this should do it but not sure what elements are for phpBB2
Code:

$(function(){
var forum=3587;
var elem=$(".news_forum");
var elem2=$(".news_user");
if(!elem.length) return;
$.get("/t"+forum+"-?view=newest", function(data){
var data2;
data=$(".postbodyinside", data).last().html();
data2=$(".postprofile > dl > dt > strong", data).last().html();
elem.html(data);
elem2.html(data2);
})
})
avatar
_Twisted_Mods_
Helper
Helper

Male Posts : 2064
Reputation : 314
Language : English
Location : Ms

http://liquidcode.forumotion.com

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