Setting to include excluded categories in homepage on mobile


(Penar Musaraj) #1

Would it make sense to add a setting that only excludes categories from the homepage on desktop clients? Or would this be something that should be handled in a plugin?

Some context: I am building a Discourse site with an un-Discourse-like layout for the topic lists. My layout has a sidebar that lists the latest posts from several categories that are excluded from the homepage. Since the sidebar is only for desktop, topics from the sidebar categories are excluded from mobile as well, and I would like to show them in mobile.

I would be happy to do this within my plugin, if it is doable. I am a newbie in Ruby, but I did find where the filtering of excluded categories is done and I tested quickly adding a check for mobile_view there, and it works. I just added the unless statement below:

if filter.to_s == current_homepage
  unless view_context.mobile_view?
    list_opts[:exclude_category_ids] = get_excluded_category_ids(list_opts[:category])
  end
end

But, help, I don’t know how to do this from within the plugin.


(Penar Musaraj) #2

Following up on this, I did not find a way yet to do this in the plugin. But I am using a small and very temporary patch, available here if anyone is interested.

It would be nice to have this as a setting though, or at least, know whether the team thinks it’s appropriate for this setting to be in core or not.


(Mans) #3

how did you do that?
I would be thankful if you share the way you list latest posts from other categories in sidebar.


(Penar Musaraj) #4

Using this plugin I just published:


#5

I would like to hide specific categories in mobile view