MyBB Community Forums

Full Version: Is it possible to add different CSS to portal announcement.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys I didn't want to make the subject really long so I cut it short but anyway the main question is that in the MyBB Portal you get to display a few threads (they call it announcements) and there is only one template and whatever you do in there is applied to all the announcements displayed on the MyBB Portal.


Now is it possible to add a different markup/CSS to some of the announcements, I have asked this before and received no constructive responses so please even if you have the slightest idea about this being a possibility then do share with me as I really need this.

Cheers and regards
what and how do you want to make them different ?
Okay so basically suppose I made a topic on my forum and now it is displayed in the portal with the markup I added in the template portal_announcment. Lets call this post #1

Now I make another topic and it is also displayed in the same layout, design whatever you call it. This is my post #2

Now both post1 and post2 are displayed in the same style, I want post #2 to differ from the first one in the portal page.
Yes, but you don't say what elements specifically you want to be different. They are exactly the same because it's a dynamic page, the only difference between posts being the tid value. Generally this is not possible. You make a style change, and it effects all them the same. If you know what you want to change specifically, then you can make a plan to do something.
I'm not sure if this is what you're asking, but if you want to add different CSS to a specific announcement, you could do something like this:

id="announcement-{$announcement['tid']}"


{$announcement['tid']} will be replaced with whatever the thread ID is, you can hover over the subject on the portal to quickly find it. For example, if the thread ID is 100, you'd add this in your CSS file:

#announcement-100 {/** whatever you need here */}

Edit:

Posts will eventually be covered up by newer posts, so this obviously isn't going to work unless you're only showing posts from certain sections which won't be bumped by other members.
I want to change the size of the two posts, I'm using material cards to display and I want to make one bigger than the other. So yeah I understand and know what I need to change but I have no idea how to do make changes that will only effect the targeted announcement.
You can target a specific announcement with the way I posted but the problem with doing it that way is that (depending on how it's set up) they will eventually be bumped down by more recent posts.

You could also edit the main portal template and just add the html from the announcement template directly above the {$announcements} variable.
Specific posts would have to be manually updated so that would get tedious. If you're wanting the CSS to alternate every other post?

id="altannouncement"

check if $announcement['tid'] is even or odd

If it's even ($announcement['tid'] % 2 == 0)
<style>
#altannouncement: /**even css**/
</style>
If it's odd ($announcement['tid'] % 2 != 0)
<style>
#altannouncement: /**odd css**/
</style>

That would probably be how I would do it tbh