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.
- This topic has 28 replies, 2 voices, and was last updated 10 years, 7 months ago by
Steven Zahm.
-
AuthorPosts
-
01/06/2016 at 5:16 pm #360209
George Socha
ParticipantSteve,
For the cMap single-entry view (card-single.php), I would like to be able to show only those categories for that entity that are under a root parent (ID=34) instead of all the categories for that entity.
In the list page (card.php) I can show all for that entity categories by using “show_categories=TRUE”. When I do that, I see all categories for that entity in the single-entry view.
Ultimately I want to see the categories only on the single-entry page and not on the list page, but first I need to figure out this step.
Thanks in advance.
George
01/06/2016 at 8:42 pm #360233Steven Zahm
Keymaster@ George
The Connections taxonomy code for categories is very heavily based on the core WordPress code… there’s actually no really easy way of doing this. Basically a custom function would need to be written which would get all the categories for an entry, check each to see if it is an ancestor of category ID:34 and then output the appropriate HTML code. This function should do the trick:
function cn_display_terms_of_parent_term_id( $term_id, $terms ) { $found = array(); foreach ( $terms as $term ) { if ( cnTerm::isAncestorOf( $term_id, $term->term_id, 'category' ) ) { $found[] = $term->term_id; } } foreach ( $found as $id ) { $category = cnTerm::get( $id, 'category' ); if ( ! is_wp_error( $category ) ) { echo esc_html( $category->name ); } elseif ( is_a( $category, 'WP_Error' ) ) { echo $category->get_error_message(); } } }You would use it in the
card-single.phpfile like this:cn_display_terms_of_parent_term_id( 34, $entry->getCategory() );That should output only the categories that were assigned to an entry with the parent ID of 34.
01/07/2016 at 4:07 pm #360306George Socha
ParticipantSteve,
That worked great. Is there some way for me to sort results – best by the order number that I get by using Connections Custom Category Order?
You can see what I have done so far at http://www.edrm.net/apersee
Thanks,
George
01/07/2016 at 4:14 pm #360307George Socha
ParticipantHere is a better example: http://www.edrm.net/apersee/name/advanced-discovery
01/07/2016 at 5:22 pm #360311Steven Zahm
Keymaster@ George
Do you have Custom Category Order installed and the order defined?
01/07/2016 at 5:23 pm #360312George Socha
ParticipantYes, I do.
01/07/2016 at 5:42 pm #360315Steven Zahm
Keymaster@ George
Ok, them. The output from
$entry->getCategory()which you are using in the above code is ordered to the number you set in the admin. When you flatten out the category hierarchy and depending on the order numbers you used it may not be apparent. To give your advice I would need to know the current order numbers, the desired order and the final code you using in thecard-single.phptemplate you used for the out so I can make sure there’s nothing there that would alter the order.01/07/2016 at 5:52 pm #360317George Socha
ParticipantSteve,
I had forgotten to enter the license number!
I have done that and now the entries appear in alphabetical order. The category numbers are gone, however, so I need to figure out what happened with the numbers.
Here is the current
card-single.phpcode:<div class="cn-clear" style="display:table;margin: 10px 0;width:100%;"> <div style="display:table-cell;vertical-align:middle;"> <?php if ( $atts['show_categories'] ) { echo '<h4>'; echo $atts['str_category_label']; echo '</h4>'; cn_display_terms_of_parent_term_id( 35, $entry->getCategory() ); } ?> </div> <div style="display:table-cell;text-align:right;vertical-align:middle;"> <?php if ( $atts['show_last_updated'] ) { cnTemplatePart::updated( array( 'timestamp' => $entry->getUnixTimeStamp(), 'style' => array( 'font-variant' => 'small-caps', ) ) ); } ?> </div> </div>01/07/2016 at 6:03 pm #360320Steven Zahm
Keymaster@ George
Ok, so now I’m a little confused. Is it like you want now?
If you do not see the option to edit the order then it sounds like the extension (plugin) is not active. The support license key being input/activated would not affect the ordering functionality, it enables the ability to support in admin updates when I release updates so they do not need manually updated.
01/07/2016 at 7:19 pm #360326George Socha
ParticipantSteve,
First I need to get back where I was. Then I will follow up with what I was trying to do.
Thanks,
George
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.
