News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Any chance to change the "topic title color" ?!?

Started by kyle007, March 28, 2008, 09:40:22 AM

Previous topic - Next topic

kyle007

I want a topic's title red...Only one topic's...And also  wanna make it bold....

Any way to do this ?

_________________________________________

Solution :

Sources/MessageIndex.php :

Code (find) Select
// 'Print' the topic info.

and above it, add


$color = $row['ID_TOPIC'] == '6395' ? 'red' : '';
$weight = $row['ID_TOPIC'] == '6395' ? 'font-weight: bold;' : '';


*6395 is the topic ID,changeable....
___________

Then down below
Code (look for) Select
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['firstSubject'] . '</a>'

change it to to...
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: '. $color. '; '. $weight .'">' . $row['firstSubject'] . '</a>'



Credits : Kender , JohnyB

Spaceman-Spiff

If you mark it as a sticky topic, you can change the CSS for .windowbg_sticky to show it red. Otherwise, I don't think there's a way to do it.

ccbtimewiz

It's quite possible. Make it so that only admins can use BBcode or HTML in their post titles.

kyle007

@Spaceman-Spiff ; it's true but,i just want to change one topic's color...


@ccbtimewiz  ; i didn't understand  what you said,pls can u explain it?

Eliana Tamerin

ccbtimewiz, that will cause bbc and html characters in the page title, which won't render properly.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

Bulakbol

Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

ccbtimewiz

Quote from: Eliana Tamerin on March 28, 2008, 05:53:53 PM
ccbtimewiz, that will cause bbc and html characters in the page title, which won't render properly.

Simply strip HTML tags in the page title.

strip_tags($context['page_title'])

Eliana Tamerin

Allowing HTML tags opens up security and layout destruction possibilities. BBC would be much safer, though I'm not sure there's a strip BBC function.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

ccbtimewiz

...

You would obviously use BBcode in the title. Then when it converts into the title, it would obviously be HTML seeing how BBcode transgorates into HTML. At that point, you would strip the HTML.

There's no difference.

Bulakbol

#9
Back to the topic.  :P

The MessageIndex.template.php refers to the topic link so you can't change the color from there. You have to change the color in the Source file. And if you are willing to edit your MessageIndex.php, here's my solution.

Code (find) Select
// 'Print' the topic info.

and above it, add
$color = $row['ID_TOPIC'] == '122' ? 'red' : '';

The number '122' is the topic id number. Change it with your topic id and change the color.

Then down below
Code (look for) Select
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['firstSubject'] . '</a>'


and replace with
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: '. $color. ';">' . $row['firstSubject'] . '</a>'
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

kyle007

@JohnyB ;

thx,i think it's the solution,but i could't find "// 'Print' the topic info." in MessageIndex.template.php, i use a different theme,couldn't find it even in the default theme... :S

Also the other codes started with "'link' => '<a href="'......."

?

Bulakbol

Sorry if my message confused you but if you will read it again, you'll find out that I was talking about Sources/MessageIndex.php and not the template. The file you have to edit is Sources/MessageIndex.php and you can find it in the Sources folder.
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

kyle007

OMG Thx so much JohnyB , it really works...Thx...

Sorry but a little que, can i make that topic also "bold" ?

Kender

style="color: '. $color. '; font-weight: bold;">


just a snip of what you have already changed with the edit to make it bold
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

kyle007

Ops, all the topics became bold with both of yours way.....  :o


Bulakbol

#15
If you don't like Kender's way, then we have to change our codes.

Replace the
$color = $row['ID_TOPIC'] == '122' ? 'red' : '';

with
if ($row['ID_TOPIC'] == '122')
$link = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: red; font-weight: bold;">' . $row['firstSubject'] . '</a>';
else
$link = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['firstSubject'] . '</a>';


and the
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: '. $color. ';">' . $row['firstSubject'] . '</a>'

with
'link' => $link,
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Kender

$weight = $row['ID_TOPIC'] == '122' ? 'font-weight: bold;' : '';


'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: '. $color. '; '. $weight .'">' . $row['firstSubject'] . '</a>'

http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

kyle007

Kender thx but what should i put between the color and bold codes ?

$color = $row['ID_TOPIC'] == '6395'  ? 'red' : '' ? 'font-weight: bold;' : '';

Kender

#18
reread my message

you would put my first line of text above or below the $color =

then you would modify the link text to read what i wrote in my second line


$color = $row['ID_TOPIC'] == '6395' ? 'red' : '';
$weight = $row['ID_TOPIC'] == '6395' ? 'font-weight: bold;' : '';


then change the link to...
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0" style="color: '. $color. '; '. $weight .'">' . $row['firstSubject'] . '</a>'

http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Bulakbol

Sorry, I was editing my message when you replied. You now have choice.  :D
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines

Advertisement: