showOpLikes - How to enable?

(Drazisil) #1

I’m sorry, this is probably really simple, but where do I toggle this to ‘true’?

(Uwe Keim) #2

Does this help?

Seems that it refers to the sorting order?!?

(Drazisil) #3

Sadly, it doesn’t. Yes, enabling it will get me a sortable column, but I can find nowhere in the code TO enable it.

(Drazisil) #4

(thinking support may be a better category for this)

(Sam Saffron) #5

Something along the lines of this would force op likes on in all lists.

require('discourse/compnents/topic-list').default.reopen({showOpLikes: true;}); 

(Drazisil) #6

Thank you. What file do I put that in?

And related, is there a way to set it for just a certain category?


(Sam Saffron) #7

you would put it in a site customization in a javascript block. doing this just for a certain category is a bit harder.

(Drazisil) #8

Really sorry if I’m coming across as dense. Do you have an example of a site customization, or am I just completely not seeing the docs?:frowning:

(Mittineague) #9

I prefer to put my JavaScript code into plugins, but many go the Admin -> Customize route. eg.
* NOTE some of these may need tweaking due to deprecation

(Charles Walter) #10

I was hoping to do the exact same thing. I was able to get likes working, but then realized OpLikes would be much better for our community.

This topic helped me enable likes as a test. If anyone figures out the full code needed to enable OpLikes, please share :slightly_smiling:

(Charles Walter) #11

To clarify, I added this code, which added a likes column, but no op like data rendered.

var TopicListComponent = require('discourse/components/topic-list').default;
    showOpLikes: true

There would appear to be an issue with this code below. Is it possible that hasOpLikes and topic.op_like_count have been deprecated?

  {{#if hasOpLikes}}
  <a href='{{topic.summaryUrl}}'>
    {{number topic.op_like_count}} <i class='fa fa-heart'></i></td>

How to Customize one category view
Sam's personal "minimal" topic list design
(Drazisil) #12

Thank you everyone. This code works:

admin -> customize -> css/html -> new style -> header

var TopicListComponent = require('discourse/components/topic-list').default;
    showOpLikes: true,

There’s some form of cache issue, after I clicked the column header for likes the data appeared.


Hey Guys, what are OpLikes exactly? How do they differ from the likes (heart) shown in this thread?

(Jeff Atwood) #14

OP “original post” aka “first post” aka “the topic itself”, in other words likes on the first post only. Not counting likes to any replies, just likes to the first post.


Thanks @charleswalter & @drazisil.

I added your code to my hosted discourse and the column is added and as stated below, the data is only rendered after the column is sorted. Perhaps the data is only being requested in the order by query and not the default query?

(Charles Walter) #16

That would make sense @ccdw. Here are the steps I took to reproduce the problem

  • added the code to header
  • ordered the items by Likes
  • returned to the regular view

Upon returning to regular view, I could see some topics with OpLikes, but only those that had made it to the top of the sorted view. Other recent topics which has OpLikes were still showing without any data.


I’m new here - should this be reported as a bug?

(Mittineague) #18

A bug report means something is broken, preventing normal/typical use of Discourse. Do be sure to search prior to submitting bugs. Include repro steps, and only describe one bug per topic please.

keyword “normal/typical”

(Charles Walter) #19

@mittineague, may not be a “bug” in the typical sense, but it would be great to know if there’s a way to see the data. A few of us are interested in showing OPlikes on our homepages.

If it’s a big change, we totally understand. If it is a simple fix, that would be music to our ears.

WIP: Customize topic list per category
(Mittineague) #20

From what I saw by looking, Likes are not in the page output.

There are like_count values in the page’s JSON - though I think those are “topic Likes” not “OP Likes”

I don’t know what the hit to resource use would be, but I think if the information was included in the pages HTML - even if not shown by default - it would be fairly easy to have it show.

Otherwise code could be used to get the like_count values from the JSON and put into the page.

If it was for only the OP Likes, I think the JSON for each individual topic would need to be retrieved.
That could affect performance quickly with all the extra HTTP requests that would be needed.

But I don’t think one call for the JSON would be that bad as long as “topic Likes” was good enough.

One problem being how to deal with the content added upon scrolling.