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.

Portal NEWS widget - show the last message

3 posters

Go down

Portal NEWS widget - show the last message Empty Portal NEWS widget - show the last message

Post by Kami-sama 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?
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Guest 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
Guest
Guest


Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

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

Yes, exactly that.

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

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Guest August 9th 2017, 6:28 pm

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


Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Kami-sama 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.
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Guest 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
Guest
Guest


Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

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

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

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Guest August 9th 2017, 7:03 pm

Yup.
avatar
Guest
Guest


Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by Kami-sama 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.
Kami-sama
Kami-sama
Forumember

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

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

Do you mean the author of the post?


Portal NEWS widget - show the last message Slgray10

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

Male Posts : 51554
Reputation : 3524
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

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

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

Female Posts : 407
Reputation : 12
Language : EN, RU, DE, LT
Location : Lithuania

http://hogas.huhohi.com/

Back to top Go down

Portal NEWS widget - show the last message Empty Re: Portal NEWS widget - show the last message

Post by _Twisted_Mods_ 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);
})
})
_Twisted_Mods_
_Twisted_Mods_
Helper
Helper

Male Posts : 2083
Reputation : 336
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Back to top

- Similar topics

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