Author Topic: Alternating colours  (Read 3612 times)

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Alternating colours
« on: March 30, 2017, 02:25:52 pm »
Hello all.

is there a way of forcing the background colour of replies of a ticket to alternate. I can't seem to do it through the css of the theme I'm using - it just doesn't alternate.

this would be useful when reviewing a long ticket.

Thanks in advance

Offline SleePy

  • Site Manager
  • Developer
  • *
  • Posts: 761
    • View Profile
    • SleePyCode
Re: Alternating colours
« Reply #1 on: April 17, 2017, 08:02:08 pm »
It can be by modifying the SimpleDesk-Display.template.php in the sd_template folder (in default theme folder)

look for:
Code: [Select]
while ($reply = $context['get_replies']())
{
if (!empty($reply['is_new']))
echo '
<a id="new"></a>';

echo '
<div class="description shd_reply', (!empty($context['ticket']['display_recycle']) && $reply['message_status'] == MSG_STATUS_DELETED ? ' errorbox' : ''), '" id="msg', $reply['id'], '">

Replace that with:
Code: [Select]
$alt = false;
while ($reply = $context['get_replies']())
{
$alt = !$alt;

if (!empty($reply['is_new']))
echo '
<a id="new"></a>';

echo '
<div class="', $alt? 'description' : 'information', ' shd_reply', (!empty($context['ticket']['display_recycle']) && $reply['message_status'] == MSG_STATUS_DELETED ? ' errorbox' : ''), '" id="msg', $reply['id'], '">
Jeremy D — Spare-Developer

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Alternating colours
« Reply #2 on: April 22, 2017, 07:10:58 am »
Thanks for this.

To make this work do I now style "description" and "information" with different background colours?

I'd try that and test it now but I'm not at my work comp', and there's a possibility you may reply to this before I am which might save some time of I am wrong.

Many thanks

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Alternating colours
« Reply #3 on: April 22, 2017, 02:05:51 pm »
Sorry for the double post but I have realised a probable flaw in this idea I've requested. I realised that if someone double posted in a ticket, the alternating colours would become confusing as they would no longer seemingly apply to the poster.

It seems what I really need is to find a way to assign a background colour to a member's id/post so that replies can be read and identified more easily.

Is that possible?

Thanks in advance.

Offline SleePy

  • Site Manager
  • Developer
  • *
  • Posts: 761
    • View Profile
    • SleePyCode
Re: Alternating colours
« Reply #4 on: April 22, 2017, 08:13:13 pm »
If you want to change the color, I would suggest creating new names, copying the existing css for information and description and then altering it to fit your needs.  Unless you want to change those globally, as they are SMF css code and used in other parts around SMF.

If you wanted to track colors by the member, it should be possible by tracking the id_member and only changing $alt when we encounter a different id_member:
Code: [Select]
$alt = false;
$last_id_member = -1;
while ($reply = $context['get_replies']())
{
if ($last_id_member != $reply['id_member'])
$alt = !$alt;
$last_id_member = $reply['id_member'];

if (!empty($reply['is_new']))
echo '
<a id="new"></a>';

echo '
<div class="', $alt? 'description' : 'information', ' shd_reply', (!empty($context['ticket']['display_recycle']) && $reply['message_status'] == MSG_STATUS_DELETED ? ' errorbox' : ''), '" id="msg', $reply['id'], '">
Jeremy D — Spare-Developer

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Alternating colours
« Reply #5 on: April 24, 2017, 05:43:29 pm »
Thanks SleePy,

I'm not really clued up enough to understand what you said in the second part of your last reply. If there is a way to have unique post background colours based in a members' ids, I'd love to know how that could be done. I have set up departments with corresponding member groups so many people can chip in and reply to a ticket.  The problem is you sort of lose who is saying what. Being able to identify them instantly would be more than useful.

I was looking at standard mods like this one:

https://custom.simplemachines.org/mods/index.php?mod=1310

but it wouldn't really do what I am asking and it probably wouldn't integrate into simpledesk of it did.


Any ideas?


Offline SleePy

  • Site Manager
  • Developer
  • *
  • Posts: 761
    • View Profile
    • SleePyCode
Re: Alternating colours
« Reply #6 on: April 28, 2017, 10:56:31 pm »
We don't support that mod, not that it couldn't be done.

The changes I suggested in my last post group replies based on the member id.  If the same member replies multiple times in a row, the color wouldn't change.
Jeremy D — Spare-Developer

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Alternating colours
« Reply #7 on: April 30, 2017, 04:15:56 pm »
Yes, I did comment that I doubted that the mod would integrate into SD.

I thought the principle was interesting, though. It seemed a more doable method (if only brute force) to assign a colour to a membergroup and then add only one user to that membergroup. This would then hopefully separate the background colour of replies by poster.

Is there perhaps a way to do that?

Offline SleePy

  • Site Manager
  • Developer
  • *
  • Posts: 761
    • View Profile
    • SleePyCode
Re: Alternating colours
« Reply #8 on: May 14, 2017, 03:27:09 pm »
There isn't a way easily to do it.  You would have to start off with that mod working in SMF, then bring in the changes it makes into the display for SimpleDesk as well.
Jeremy D — Spare-Developer

Offline smokester

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Alternating colours
« Reply #9 on: May 14, 2017, 05:05:40 pm »
I have a sandboxed version installed locally that I use for testing.  I'll play around with it and see if I can get it to work. 

I may well need a little more help modifying the SD display template, though.