<div> tag, and adding 'online/offline' status to profiles

Started by Mari-chi, August 09, 2011, 08:59:12 PM

Previous topic - Next topic

Mari-chi

I have two things that I'd like to do... :)

1. How can I allow just the <div> tag in profile signatures? I know the risks of allowing HTML for all members, but I just want to allow the <div> tag so that people can style their signatures as they please.

2. I am trying to add this bit of online/offline code to the profile section (below the avatar):
// Show online and offline buttons?
if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'] && $message['member']['online']['is_online'])
echo '
', $context['can_send_pm'] ? '<span title="' . $message['member']['online']['label'] . '">' : '', 'Status: <span style="color: #4c8b2a;">', $txt['online'],'</span><br />', $context['can_send_pm'] ? '</span>' : '';

// Show online and offline buttons?
elseif (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'] && !$message['member']['online']['is_online'])
echo '
', $context['can_send_pm'] ? '<span title="' . $message['member']['online']['label'] . '">' : '', 'Status: <span style="color: #8b2a2a;">', $txt['offline'],'</span><br />', $context['can_send_pm'] ? '</span>' : '';


It should look like this: http://adlucem.net/index.php?topic=298.0 (see "Status: Offline" or "Status: Online" below the avatars of posters), but it always appears "Offline" in the profile area, no matter if the member is online or offline. Could someone help me to get it display correctly?


Thank you! :)

Hj Ahmad Rasyid Hj Ismail


Mari-chi

Nope, that doesn't work either. :S


ETA: Rather than trying to use the code I posted in my lead post, how would I be able to use this (it was in profile.template.php):

<span id="userstatus" class="profileonoff">Status: ', $context['can_send_pm'] ? '' : '', $settings['use_image_buttons'] ? '' : $context['member']['online']['text'], $context['can_send_pm'] ? '' : '', $settings['use_image_buttons'] ? '' . $context['member']['online']['text'] . '</span>' : '

When a member is online, I would like the word "Online" to be #4c8b2a, and when a member is offline, I would like the word "Offline" to be #8b2a2a.

Mari-chi

No! It works! 8D Thank you!! I'm not sure why it didn't work on your forum, but it works perfectly on mine. :D Thanks again!

Now I just need a way for the <div> tag to work in signatures, if anyone can help me with that. ^^


ETA: Okay it looks great on the profiles, but it breaks the online/offline status in PMs. Gah.

Hj Ahmad Rasyid Hj Ismail

Forget about the above mod. Restore your index.english.php back if you haven't done that yet. I made some code and did further tests and I got it now.

Here goes. Open Profile.template.php and at the line that you provide above, find:
$settings['use_image_buttons'] ? '<span class="smalltext"> ' . $context['member']['online']['text'] . '</span>' : '';
Change it to:
$settings['use_image_buttons'] ? '<span class="smalltext"> ' . ($context['member']['online']['is_online'] ? '<span style="color:#4c8b2a">Online</span>' : '<span style="color:#8b2a2a">Offline</span>') . '</span>' : '';

I hope this work for you as well. Good luck and best wishes.

Mari-chi

@ahrasis: That works! Thank you very much for your help! :D




Still searching for a way to accomplish #1!

Hj Ahmad Rasyid Hj Ismail


Mari-chi

I just installed the Ultimate Profile mod on a test forum, but a regular member still cannot use the <div> tags in their signatures. Is there something I'm missing? ???

Also, I've used the Ultimate Profile mod before, but did not like it, so I am only looking to let members use the <div> tag in their signatures. :S

Hj Ahmad Rasyid Hj Ismail

To allow div tag in signature is to allow html in signature. IMO it is built in.

Mari-chi

There is a section to customize the look of the profile through the Ultimate Profile mod using HTML and CSS, but that's about it, nothing to use HTML and/or CSS for a signature. :S

Then, is it possible to allow HTML, but filter out scripts?

Hj Ahmad Rasyid Hj Ismail

Quote from: ahrasis on August 13, 2011, 01:28:17 PM
To allow div tag in signature is to allow html in signature. IMO it is built in.
It is a builtin in SMF not UP and must be allowed in signature as I mentioned earlier. ACP > Configuration > Features and Options > Signatures.

To use:[html]Put your html code here![/html]


Illori

but only admin can use the html bbc code tag so that does not work.

Mari-chi

Yeah, that's the problem I'm having. :S Only admins can use the [*html] tag.

I did enable all bbc tags through features and options > signatures already.

So to clarify, what I'm asking for:
* Allow the use of [*html] tag for all members
* Filter out any scripts, OR:
* Allow only the <div> tag within the  BBC tag

Hj Ahmad Rasyid Hj Ismail

Yes. It is for admin only.

For others, they need to manipulate the other BBC tags. There is no real need to allow them to use html and as said by many, too risky. If you need a flash to be allowed in signature, I think, there is a mod to do that.

Just in case you still want to do it i.e. to allow all members to use html, try looking into "function profileValidateSignature(&$value)" in Profile-Modify.php. Good luck.

Mari-chi

ㅠㅠ No, I don't need flash or anything like that. I just want them to be able to use the <div> html tag to style their signatures any way they want (ex. rounded corners, backgrounds, div boxes, etc.)...

Thanks for the input though, ahrasis :)

WillyP

Even if you could filter out scripts, and allow only 'div', you members would still have the power to break the visual layout of your site, because most of them don't know enough about html to do this correctly. And so you will be constantly troubleshooting and correcting faulty html in sigs, only to do it again when the member who's sig you just fixed decides your 'fix' wasn't to their liking. BTDT!

Mari-chi

ㅠㅠ That's okay. I'm okay with fixing coding errors.

If not that, is there a mod that converts the <div> html tag into BBCode? For example:

<div style="border-radius: 5px; background: #000; color: #fff;">hello</div>

would be, in BBCode:

[div style="border-radius: 5px; background#000; color: #fff"]hello[/div]

etc.

Hj Ahmad Rasyid Hj Ismail

I don't think that is possible but you can always use this to help you convert basic html to bbcode.

http://www.seabreezecomputers.com/html2bbcode/

Advertisement: