News display: exclude entries with a specific (secondary) category

Post

Posted
Rating:
#3115 (In Topic #575)
Avatar
Standard member
jacobgkau is in the usergroup ‘Well-settled’

Include a broad (main) category, but exclude a specific (secondary) category

Greetings,

First, allow me to explain what I am trying to do, because there is a specific logic to this question. On my website, I post videos as news entries. Each video has a main category representing its general genre. Some videos also have a secondary category, which would be the "series" or "show" they belong to.

So, for example:
Video title: Rolling Release Technology News, Episode 10
Main Category: Technology
Secondary Category: Rolling Release

This allows me to have show pages which select news by the secondary category to show only the videos that belong to a specific series. It works great!

Now, if you hover over one of the broad categories in the top navigation, you'll notice each one has an "All" option. This, of course, selects news by the general category, which includes both show episodes, and miscellaneous videos in that category.

What I am now trying to do is add an actual "Miscellaneous" page for each category. So, for example, I want a "Miscillanous Tech" page that shows any tech videos which are NOT part of the Rolling Release series.

So, basically, "news_category = x AND news_entry_category != y".

My problem is that Filtercode understands "news_category" but not "news_entry_category". Simply selecting "news_category!=y" does not work, because "news_category" seems to only store the main category, and any secondary categories are stored in a separate database table under the "news_entry_category" field.

I've looked into using Selectcode for this as well, but it seems that once you select an item under one argument of Selectcode, you cannot remove that item with any other argument of Selectcode. (Selectcode is inclusive by nature.) Additionally, Selectcode seems to only work with the main category for deselecting, even though it does work with secondary categories for selecting.

So, I'm still thinking my best bet is Filtercode, but I don't know how to make Filtercode work with secondary categories. Is it possible? Does anyone have ideas on how to accomplish this?

I am willing to create custom blocks or do other light development if need be, as I have already done a decent amount of development with my Composr website to make it work the way it does now.

Finally, I am aware that I could just add a "Miscellaneous" category and apply it as a secondary category to everything that's not in a series. That will be my last resort, but because I have over five hundred entries and I would have to apply the category to most of these entries manually, I thought I would check here to see if anyone has ideas on accomplishing this in a cleaner/more direct manner first.

Thanks in advance for any help or insights!

P.S.: I wasn't quite sure if this was the right forum section for this. My apologies if it would belong somewhere else, but because I'm attempting to use built-in Composr functionality, I wasn't confident that it would fit under the "Developing" section.
Online now: No Back to the top

Post

Posted
Rating:
#3120
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Hi,

Seems like a bug to me, I was able to reproduce with a simple test data set, now digging into it.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3121
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
I've fixed the issue.

It's not a perfect fix because fundamentally Selectcode isn't designed for searching multiple fields, but it should work now enough. I've changed the two category fields to be searched with an 'AND' between their conditions rather than an 'OR', if the Selectcode conditional is a negative condition (i.e. ! or ~ is in the Selectcode).

Attachment

sources/blocks/main_news.php



Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#3152
Avatar
Standard member
jacobgkau is in the usergroup ‘Well-settled’

Chris Graham said

I've fixed the issue.

It's not a perfect fix because fundamentally Selectcode isn't designed for searching multiple fields, but it should work now enough. I've changed the two category fields to be searched with an 'AND' between their conditions rather than an 'OR', if the Selectcode conditional is a negative condition (i.e. ! or ~ is in the Selectcode).

Wow! Thank you so much! I just implemented your changes into my site, and it works beautifully.

Sorry I didn't respond earlier, but Gmail marked Composr's notification email as spam for some reason, so I only just saw it today.

Thanks again!!
Online now: No Back to the top
1 guest and 0 members have just viewed this.

Statistics

Forum statistics:
  • 2,052 topics, 7,195 posts, 10,830 members
  • Our newest member is Customcollective
Back to Top