Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.5.22, category, cn_entry_output_category_item, filter
- This topic has 10 replies, 2 voices, and was last updated 9 years, 11 months ago by
Steven Zahm.
-
AuthorPosts
-
08/18/2016 at 1:23 pm #386975
Carolin Collins
ParticipantHi Steve
Is it possible to hide categories from displaying on a listing’s card in the same way we can hide categories in the sidebar of the directory? Our members tag themselves under 5 different category groups in their member form in the backend. However, we only want to display 2 of these category groups in the front end. That is working great for the sidebar hierarchy by using the widget settings.
However, in a member’s listing, all entries from all 5 category groups are still shown. Is it possible to somehow restrict these as well so that I can match what is in the sidebar?
Thanks!
08/18/2016 at 2:22 pm #386976Steven Zahm
Keymaster@ Carolin
Hmmm… good question actually. Let me look in the code real quick…
08/18/2016 at 2:48 pm #386979Steven Zahm
Keymaster@ Carolin
Yes, but not perfectly…
You can hook into the
cn_entry_output_category_itemfilter and check for a “permitted” category ID and if one is not found return an empty string. Something like this:add_filter( 'cn_entry_output_category_item', 'cn_remove_entry_output_category_item', 10, 6 ); function cn_remove_entry_output_category_item( $html, $category, $count, $i, $atts, $entry ) { if ( in_array( $category->term_id, array( x, y ) ) ) { return $html; } return ''; }Change
xandyin the code snippet to the two category ID/s that you want to be displayed. Al other will be tossed.Now, I said this is not perfect… You’ll end up with “extra” commas where the categories should have been displayed — I think. If you do, the next update, I added extra logic, jujst now to make sure that will not happen.
Hope this helps!
08/29/2016 at 6:59 am #388062Carolin Collins
ParticipantHi Steven!
Probably a stupid question but this goes into the card.php file within the cmp folder, correct?
Just wondering though whether this code would separate out the categories by parent group or does it still leave them all mixed up together like in the current list?
If separating out would require a customisation job, then can you please mail me a quote for this as it is definitely what the client is looking for prior to going live to ensure that the card’s content is aligned with the search options in the left sidebar. Basically, we would look for the categories to be listed in groups, with the category group name first and then followed by the children selected by the relevant member in that group, then preferably a paragraph break (but line break at minimum) followed by the next category group name and children.
Would that be possible? Thanks for your advice and help as always.
08/29/2016 at 9:37 am #388090Carolin Collins
ParticipantSorry, forgot to say that I don’t mean the original card.php file but the relevant override file.
08/29/2016 at 3:07 pm #388107Steven Zahm
Keymaster@ Carolin
re: Probably a stupid question but this goes into the card.php file within the cmp folder, correct?
No, you would add this as a new snippet using the Code Snippets plugin.
re: Just wondering though whether this code would separate out the categories by parent group or does it still leave them all mixed up together like in the current list?
No, this does nothing to group by parent, only display the category (by ID) which you do want to be displayed.
re: If separating out would require a customisation job
Yes, to group by parent, this would require custom work to the template.
re: can you please mail me a quote for this
Sure! Could you toss together a quick mockup of how you would like this presented first? I’m thinking you want something like this, but want to be certain (category names just for presentation, not accuracy :) ).
Industry/Sector: Coaching & Mentoring, Commercial/Legal/IP, General Management
Role/Function: Coaching & Mentoring, Commercial/Legal/IP, General ManagementIn event that there are no categories assigned for one or both, do not display the parent category label, correct?
08/29/2016 at 3:21 pm #388108Carolin Collins
ParticipantOh, I’m a plonker about the Code Snippet plugin – of course!!
With regards to the mock-up, what you have suggested there is exactly what I am looking for. Preferably with a paragraph separator between categories rather than line-break – if at all possible. And perhaps the parent categories could be in bold?
Industry/Sector: Agriculture, Healthcare, Logistics
Role/Function: Coaching & Mentoring, Commercial/Legal/IP, General Management
08/29/2016 at 3:22 pm #388109Carolin Collins
ParticipantParagraph separator less important if we can make the parent categories bold (if I can do that myself with CSS that’s fine too).
08/29/2016 at 5:23 pm #388122Steven Zahm
Keymaster@ Carolin
One separator is just as easily done as they other, same with the bold. I just emailed you a quote. I can lean on existing code so I can do this relatively quickly and therefore inexpensively.
08/30/2016 at 3:12 am #388180Carolin Collins
ParticipantThanks, Steven. Let’s go ahead with that quote.
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
