Milk
New Member
Posts: 59
inherit
185504
0
Sept 22, 2021 13:14:00 GMT -8
Milk
59
November 2012
wolfmilk
|
Post by Milk on Feb 24, 2017 4:31:45 GMT -8
Is there someway I can remove the <span class="likes"></span> part of the Post List Layout Template, if the post has no likes?
If the post has no likes, it still displays <span class="likes"></span>. I want to remove this span element altogether if there are no likes. If there are likes, then I want it to appear as normal.
Is this possible? I've tried something like this: (but it doesn't work)
{if $[post.likes]}
$[post.likes]
{/if}
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Feb 24, 2017 9:59:13 GMT -8
I have likes removed entirely on my themes so just hazarding a guess: can you try putting a conditional amount such as:
{if $[post.likes] >= 1}
|
|
Milk
New Member
Posts: 59
inherit
185504
0
Sept 22, 2021 13:14:00 GMT -8
Milk
59
November 2012
wolfmilk
|
Post by Milk on Feb 24, 2017 15:36:50 GMT -8
I have likes removed entirely on my themes so just hazarding a guess: can you try putting a conditional amount such as:
{if $[post.likes] >= 1}
Unfortunately, that removed the likes entirety, regardless of whether someone had liked the post or not. But thank you for trying to help!
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Feb 24, 2017 15:49:57 GMT -8
|
|
Milk
New Member
Posts: 59
inherit
185504
0
Sept 22, 2021 13:14:00 GMT -8
Milk
59
November 2012
wolfmilk
|
Post by Milk on Feb 24, 2017 16:07:36 GMT -8
I poked around there, but it doesn't seem to be helping with my issue.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Feb 24, 2017 16:25:07 GMT -8
I poked around there, but it doesn't seem to be helping with my issue. What did you try, exactly? Maybe we can work off of that. The issue that I see with what I linked to vs this span is that the span class is the same, whereas with labels an empty span produces a different class from a full one. Perhaps Chris shed some light on the issue?
|
|
Milk
New Member
Posts: 59
inherit
185504
0
Sept 22, 2021 13:14:00 GMT -8
Milk
59
November 2012
wolfmilk
|
Post by Milk on Feb 24, 2017 16:37:27 GMT -8
I poked around there, but it doesn't seem to be helping with my issue. What did you try, exactly? Maybe we can work off of that. The issue that I see with what I linked to vs this span is that the span class is the same, whereas with labels an empty span produces a different class from a full one. Perhaps Chris shed some light on the issue? I was trying to test this out: <script> $('.js-no-labels').hide().parent('.thread-labels').hide(); </script>> But in my case, I don't have a 'js-no-labels' equivalent. If there are no likes, then it's simply an empty span. I'm unsure if this would help, but I'm trying something like this: (still doesn't work at the moment) <script> $(document).ready(function(){ if ($(".likes").html().length > 0) { $('.likes').show(); } else { $('.likes').hide(); } }); </script>
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,018
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Feb 24, 2017 18:19:12 GMT -8
$[post.likes] would not yield a number to compare numerically against but {if $[post.likes.total] >= 1} should so try that...
The last post about show/hide via script has me puzzled though because if it is an empty span then it should effectively be hidden anyway. The only reason to remove it is if you do not want any liking going on, an unliked post can be later liked but if that empty span is missing that will cause an error when the action to like looks for where to register this new like.
|
|
Milk
New Member
Posts: 59
inherit
185504
0
Sept 22, 2021 13:14:00 GMT -8
Milk
59
November 2012
wolfmilk
|
Post by Milk on Feb 24, 2017 19:41:14 GMT -8
$[post.likes] would not yield a number to compare numerically against but {if $[post.likes.total] >= 1} should so try that... The last post about show/hide via script has me puzzled though because if it is an empty span then it should effectively be hidden anyway. The only reason to remove it is if you do not want any liking going on, an unliked post can be later liked but if that empty span is missing that will cause an error when the action to like looks for where to register this new like. Thank you so much! It works perfectly. Fair enough. When I made that script, I was grasping at straws trying to find a solution.
|
|