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 Wed Aug 09 2017, 18:10

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 Wed Aug 09 2017, 18:21

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 Wed Aug 09 2017, 18:24

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 Wed Aug 09 2017, 18:28

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 Wed Aug 09 2017, 18:30

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 Wed Aug 09 2017, 18:49

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 Wed Aug 09 2017, 19:03

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 Wed Aug 09 2017, 19:03

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 Wed Aug 09 2017, 19:12

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 Wed Aug 09 2017, 20:01

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 : 51482
Reputation : 3519
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 Wed Aug 09 2017, 20:03

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_ Mon Aug 21 2017, 15:56

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 : 2108
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