Advertisement:

Author Topic: doubt with hardcoded text  (Read 419 times)

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,004
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
doubt with hardcoded text
« on: January 31, 2019, 12:06:41 PM »
I am trying to create a modification for the users to change color, which everything is fine or so I thought. I was thinking about sending it to SMF when I realize something:

Code: [Select]
<a href="' . $scripturl . '?action=profile;u='. $message['member']['id'] . '" style="color: ' . $message['member']['color'] . ';" title="' . $txt['profile_color'] . ' ' . $message['member']['name'] . '">', $message['member']['name'], '</a>';
I have reference other modifications of how to add it and I remembered hardcoded text is not accepted... Search and look at several codes but I can not find what I want :'( How can I get it out and fulfill the same function "style="color:"?


Regards!

ADD: Looking at some SMF files I found that in Subs-MembersOnline.php on the line 106-110:
Code: [Select]
// Some basic color coding...
if (!empty($row['online_color']))
$link = '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '" style="color: ' . $row['online_color'] . ';">' . $row['real_name'] . '</a>';

That is why I am doubtful about the regulation for the approval of the modifications! ???
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,697
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: doubt with hardcoded text
« Reply #1 on: January 31, 2019, 12:12:59 PM »
If I understand right, and that's part of the url - then no worries. Hardcoded text refers to actual text output, which should be translatable.
To do a translatable string, you just use a $translatablestring and add a corresponding language string in modifications.english.php :)
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum.
 Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Offline SychO

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 1,534
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: doubt with hardcoded text
« Reply #2 on: January 31, 2019, 12:14:08 PM »
hardcoded text refers to hardcoded language text strings, not inline CSS which is what I'm assuming you mean
looks okay since there is no better way of assigning custom colors
Take the initiative

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,565
  • Gender: Male
    • Kindred-999 on GitHub
Re: doubt with hardcoded text
« Reply #3 on: January 31, 2019, 12:14:21 PM »
that's not hardcoded text... :)


color is a CSS statement and, as such is acceptable.

However, you are including that because you have included inline styles.
Those should be avoided, in favor of actual CSS, if possible.
Instead of
style="color: ' . $message['member']['color'] . ';"
try something like
class="colorize-'. $message['member']['color'] .';"

and then in the CSS file
a.colorize-blue { color:"blue"; }
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Rock Lee

  • Native Language Support Specialist
  • SMF Hero
  • *
  • Posts: 3,004
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: doubt with hardcoded text
« Reply #4 on: January 31, 2019, 12:20:00 PM »
To my mistake then for misinterpreting it :P what modifications.english.php with the previous envie I understood, now I just need to solve that. Thank you so much @Lex!

@Kindred That way I had thought about it but in this case what I try to achieve is to assign each member a predetermined color, which I do not know how to achieve it the way you tell me. It can be easier if the same user declares said variable and I keep it together with other configurations of the user but I am again in the same doubt when I show that color to each user.

hardcoded text refers to hardcoded language text strings, not inline CSS which is what I'm assuming you mean
looks okay since there is no better way of assigning custom colors

Looking at other modifications and looking for several references I found the best solution, but I was left with some doubts when translating some words I did not finish understanding them.
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Offline SychO

  • On Hiatus
  • SMF Hero
  • *
  • Posts: 1,534
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: doubt with hardcoded text
« Reply #5 on: January 31, 2019, 12:38:28 PM »
Kindred's right if you were to give users a selection of colors to choose from, however if the users specify the color value themselves then there is no better way of doing it then how you're doing it.
Take the initiative