By Inspire Theme LTD on Saturday, 30 July 2016
Replies 11
Likes 0
Views 0.9K
Votes 0
Hi again guys,

In ED4.x there is an "is-read" class added to all discussions that have been read by the logged in user.

This is great, but the opposite is a much more useful and needed feature - usually, one would want to style the unread discussions differently, not the ones that have already been read.

You might suggest to style the default class (.ed-forum-item__title) as I would want the unread discussion to be shown and then remove/adjust it with the "is-read" class. But it doesn't really work, because all visitors, who are not logged in, will actually see the style for unread discussion instead of the default one.

Here, have a look at the attached screenshot. I'd like to add a "NEW" badge to the unread discussions and by doing the above "workaround", all not logged in visitors see it.

So, in short - please add "not-read" class as well. Thanks!

UPDATE: Make sure you implement the "not-read" class in "Recent" view as well
Hello Ivo,

Hm, it actually depends on how your css is written. If you want an opposite of is-read, you can style .is-read to be something different.

For instance, to have that new label visible,


.ed-forum-item .new-label{
display: inline-block;
}

.ed-forum-item.is-read .new-label{
display: none;
}


.
·
Saturday, 30 July 2016 12:54
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark,

As I wrote in my post above, this is exactly what I tried but it is really not a good "workaround":

You might suggest to style the default class (.ed-forum-item__title) as I would want the unread discussion to be shown and then remove/adjust it with the "is-read" class. But it doesn't really work, because all visitors, who are not logged in, will actually see the style for unread discussion instead of the default one.


Just try what you suggested and then see how it looks when you are not logged in - all discussion will have the style for an unread discussion which is not what one would want.

The thing is that "is-read" is added/rendered only for the logged in users and the "not-read" should be the same - rendered for the logged in users only.

Now, when you are suggesting the "workaround" that I already tried, which is not an acceptable "workaround", does that mean that you are not interested in implementing this (really needed) feature?
·
Saturday, 30 July 2016 15:18
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark,

I just want to add that there is "is-unread" class in ED3.x (see the attached screenshot).
So I'm really wondering why you decided to not implement it in ED4.x as well.

No, Mark, look.... adding a class to the unread discussions is a much more needed "feature" than adding a class to the read discussions.

I would also want to ask you to add a class to the top level discussion container (it is the "ed-forum-item" element) depending on the discussion status. For example, add the "is-resolved" class to the top level discussion element. That's how we can style the whole element differently, depending on the discussion status. It is like this in ED3.x, as you can see in the attached screenshot

Please Mark, please... if you just think about it you will realize that both classes ("is-unread" and the status class, for example "is-resolved") need to be implemented in ED4.x
·
Monday, 01 August 2016 02:11
·
0 Likes
·
0 Votes
·
0 Comments
·
Oops, forgot the attachment
·
Monday, 01 August 2016 02:12
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Mark,

I just wanted to ease your work a bit, so here are the files that need to be modified (speaking just about the default "wireframe" theme):

com_easydiscuss/themes/wireframe/favourites/default.php
com_easydiscuss/themes/wireframe/forums/item.php
com_easydiscuss/themes/wireframe/groups/item.php
com_easydiscuss/themes/wireframe/myposts/default.item.php
com_easydiscuss/themes/wireframe/posts/item.php


All that has to be done is:

1. Change this line:

<?php echo $post->isSeen($this->my->id) ? ' is-read' : '';?>


To this:

<?php echo $post->isSeen($this->my->id) ? ' is-read' : ' is-unread';?>


2. Add the following line:

<?php echo $post->isResolved() ? ' is-resolved' : '';?>


That's all that I'm asking for - editing 5 files and adding a line of code.
And it will really not affect performance or backward compatibility if these are your concerns

Mark, the above will make your software better, you know it.
I just cannot create template overrides for 5 files just to do these small changes, while they should really be part of the software by default.

I really hope that I've convinced you
·
Monday, 01 August 2016 05:59
·
0 Likes
·
0 Votes
·
0 Comments
·
Thanks for your input



1. Change this line:

<?php echo $post->isSeen($this->my->id) ? ' is-read' : '';?>


// Replace to

<?php echo $post->isSeen($this->my->id) ? ' is-read' : ' is-unread';?>


I already discuss with our team regarding this, we will implement this in next release version.


<?php echo $post->isResolved() ? ' is-resolved' : '';?>

By the way, this already implement in the listing page.

<ol class="g-list-inline ed-post-item__post-meta">

<?php if ($post->isResolved()) { ?>
<li><span class="o-label o-label--success-o"><?php echo JText::_('COM_EASYDISCUSS_RESOLVED');?></span></li>
<?php } ?>
·
Monday, 01 August 2016 19:23
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you for implementing the "is-unread" class.

Regarding "is-resolved" - please, please, please..... please Alrex, please read what I have written in my previous comments, please man, please!

I'm asking that the "is-resolved" class is added to the top level discussion container (it is the "ed-forum-item" and "ed-post-item" elements). That's how we can style the whole element differently, depending on the discussion status.

The code you pasted above just adds the "Badge" (with text "Resolved") to the resolved discussions, it does not add a class to the top level discussion container ("ed-forum-item" and "ed-post-item"). Therefore, the user cannot style the whole discussion container differently depending on the discussion status.

Please implement this for both "Forums" view ("ed-forum-item") and "Recent (and others)" view ("ed-post-item").

Guys, I would be really surprised if you do not want to implement this and if you are not able to see the benefit of it.
·
Monday, 01 August 2016 19:46
·
0 Likes
·
0 Votes
·
0 Comments
·
Hey Arlex, Mark,

I just noticed that my suggestion is not good and there's no point of it. This code is NOT good:

<?php echo $post->isSeen($this->my->id) ? ' is-read' : ' is-unread';?>


The code is not good because it adds the "is-unread" class for NOT logged in users as well, which makes it useless.

The "is-read" class is added ONLY for the logged in users, ONLY if they have read the discussion.
The "is-unread" class should be the same - added for the logged in users ONLY.

So, I dug in your code and I found the functions in administrator/components/com_easydiscuss/includes/post/post.php. There is a function called isStillNew() and in its comment I see the following:

     * Determines if the post is still within the new duration
*
* @alternative for previous ->isnew


But this function does not do what we want.

So, here is my final solution:

1. Create a new function. Here it is:

    public function isSomething($userId = null)
{
$items = array();
$user = ED::user($userId);

// Construct the key
$key = $user->id . $this->post->id;

// Default is unseen for guests.
if (!$user->id) {
return false;
}

if (!isset($items[$key])) {

$items[$key] = ($this->post->legacy || $user->isRead($this->post->id)) ? false : true;
}

return $items[$key];
}


2. Then use the following in the 5 files I mentioned above (leave the isSeen line as somebody might need it):

        <?php echo $post->isSeen($this->my->id) ? ' is-read' : '';?>
<?php echo $post->isSomething($this->my->id) ? ' is-unread' : '';?>


Of course, think of a meaningful name of the function, not isSomething()

So, please implement this solution. There is no point to implement the previous one we discussed.
·
Tuesday, 02 August 2016 05:42
·
0 Likes
·
0 Votes
·
0 Comments
·
We are really appreciated with your opinions and feedback, I will discuss with our team and consider implement this in the future version.
·
Tuesday, 02 August 2016 22:01
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you Arlex!
I really hope that you will implement this for 4.0.8 as I cannot wait another month or two.

As you probably remember, the only working "EasyDiscuss for OSMap" plugin that I have is for ED4.x so I need to update.

P.S. I already provided the solution. You can just polish up the PHP function a little bit and then commit it. The whole implementation will take 2 minutes.
·
Tuesday, 02 August 2016 22:15
·
0 Likes
·
0 Votes
·
0 Comments
·
You're welcome.
·
Wednesday, 03 August 2016 17:13
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post