How to change the color of First post of the topic

Looking for an Extension? Have an Extension request? Post your request here for help. (Note: This forum is community supported; while there is an Extensions Development Team, said team does not dedicate itself to handling requests in this forum)
Ideas Centre
Post Reply
User avatar
KhurramMunawar
Registered User
Posts: 534
Joined: Tue Mar 25, 2014 2:20 am
Location: Islamabad, Pakistan
Name: Khurram Munawar
Contact:

How to change the color of First post of the topic

Post by KhurramMunawar » Wed Nov 22, 2017 12:46 pm

Is there any possibility to change the color of the first post of the topic ? (first post only )

many thanks
My forum:
DearHelper.org
Get Free Traffic To Your Website
Trafficonic.com - Free Traffic To Your Website

User avatar
david63
Registered User
Posts: 16708
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: How to change the color of First post of the topic

Post by david63 » Wed Nov 22, 2017 2:45 pm

Which colour do you want changing? Text? Background? Border? or something else?

Is this "new" colour an existing colour of the style or is it any colour that the User chooses?

Is the colour defined by the Admin or the User when posting?

Does the same colour apply to all fora or is it selectable by forum?

It would help when making an extension request if you could be specific as to what you want - that way you may stand a chance of somebody actually doing it.
David
Remember: You only know what you know and - you don't know what you don't know!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

User avatar
ViolaF
Registered User
Posts: 1457
Joined: Tue Aug 14, 2012 11:52 pm

Re: How to change the color of First post of the topic

Post by ViolaF » Wed Nov 22, 2017 2:58 pm

i think, he means the background-colour of the post itself ;)

User avatar
Ger
Recognised Extension Developer
Posts: 1887
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: How to change the color of First post of the topic

Post by Ger » Wed Nov 22, 2017 3:16 pm

Should be quite easy to pass the $topic_data['topic_first_post_id'] to the template and add a class indicating the first post to the post div. You can assign any CSS you like to that class.
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
KhurramMunawar
Registered User
Posts: 534
Joined: Tue Mar 25, 2014 2:20 am
Location: Islamabad, Pakistan
Name: Khurram Munawar
Contact:

Re: How to change the color of First post of the topic

Post by KhurramMunawar » Wed Nov 22, 2017 3:17 pm

i just want to make the first post prominent than the replies.
and that could be by changing the post Background color or the text color.

and that should apply to all first posts of all the topics in the fora.

Thanks
My forum:
DearHelper.org
Get Free Traffic To Your Website
Trafficonic.com - Free Traffic To Your Website

User avatar
KhurramMunawar
Registered User
Posts: 534
Joined: Tue Mar 25, 2014 2:20 am
Location: Islamabad, Pakistan
Name: Khurram Munawar
Contact:

Re: How to change the color of First post of the topic

Post by KhurramMunawar » Wed Nov 22, 2017 3:19 pm

Ger wrote:
Wed Nov 22, 2017 3:16 pm
Should be quite easy to pass the $topic_data['topic_first_post_id'] to the template and add a class indicating the first post to the post div. You can assign any CSS you like to that class.
thanks for the suggestion.
I am not very good in doing as you directed. I need complete tutorial :mrgreen:
My forum:
DearHelper.org
Get Free Traffic To Your Website
Trafficonic.com - Free Traffic To Your Website

User avatar
Ger
Recognised Extension Developer
Posts: 1887
Joined: Wed Jan 02, 2008 7:35 pm
Location: 192.168.1.100
Contact:

Re: How to change the color of First post of the topic

Post by Ger » Wed Nov 22, 2017 3:34 pm

Well, you create an extension (might want to use the Skeleton Extension tool) that uses the event core.viewtopic_modify_post_row
Than create a function that's called upon that event:

Code: Select all

public function is_first_post($event)
{
    $post_row = $event['post_row'];
    $topic_data = $event['topic_data'];
    $post_row['S_TOPIC_FIRST_POST'] = ($post_row['POST_ID'] == $topic_data['topic_first_post_id']);
    $event['post_row'] = $post_row;
}
Next, you create 2 template files that hook into viewtopic_body_postrow_post_before and viewtopic_body_postrow_post_after to add a surrounding div like

Code: Select all

<!-- IF S_TOPIC_FIRST_POST --><div class="topic_first_post"><!--ENDIF -->
and

Code: Select all

<!-- IF S_TOPIC_FIRST_POST --></div><!--ENDIF -->
And you create a CSS file that has something like

Code: Select all

.topic_first_post .post {
	background-color: #F00; 
}
Please note that I've just written this from the top of my head so totally untested and it might just as well be bugged :mrgreen:
My extensions:
Simple CMS, Feed post bot, Avatar Resize, Modbreak, Magic OGP, Live topic update, Modern Quote, Quoted Where (GDPR) and Autoresponder.
Newest: FAQ manager for 3.2

Like my work? Buy me a coffee to keep it coming. :ugeek:
-Available for custom work-

User avatar
KhurramMunawar
Registered User
Posts: 534
Joined: Tue Mar 25, 2014 2:20 am
Location: Islamabad, Pakistan
Name: Khurram Munawar
Contact:

Re: How to change the color of First post of the topic

Post by KhurramMunawar » Wed Nov 22, 2017 3:55 pm

Thank you so much for the great help.
My forum:
DearHelper.org
Get Free Traffic To Your Website
Trafficonic.com - Free Traffic To Your Website

Post Reply

Return to “Extension Requests”