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 14 replies, 2 voices, and was last updated 7 years, 8 months ago by
Steven Zahm.
-
AuthorPosts
-
10/05/2014 at 7:19 am #306026
Fabrice Locher
ParticipantHi
I need a function which output only categories of a specific parent category. I have copied the “getCategoryBlock” in the class.entry-output.php and named it to “getAbteilungen”. But I don’t understand the
$categories = $this->getCategory()
. I only know the “get_categories()” function of wordpress. There I can say (for example)child_of = 3
. How can I do this for the connections categories?Thanks for your help!
Regards
10/06/2014 at 9:41 am #306139Steven Zahm
Keymaster@ Fabrice
Sorry, right now this is not possible unless you use unsupported, still under development code.
To call the raw data you would use this:
// Grab an instance of the Connections object. $instance = Connections_Directory(); $terms = $instance->term->get( array( 'child_of' => 3 ) );
$terms
will contain an array of the children of category ID 3 which you can loop thru and output.Hope that helps!
10/06/2014 at 5:10 pm #306248Fabrice Locher
ParticipantThis reply has been marked as private.10/07/2014 at 10:57 am #306273Steven Zahm
Keymaster@ Fabrice
Sorry, I think I mis-read my code, try this instead:
$terms = cnTerm::get( array( 'child_of' => 3 ) );
10/07/2014 at 11:00 am #306274Steven Zahm
Keymaster@ Fabrice
re: If I would get the name of the category I can get it with $term->name (in a foreach loop)?
Yes, the term name will be included in the results.10/07/2014 at 12:08 pm #306288Fabrice Locher
ParticipantThis reply has been marked as private.10/07/2014 at 12:24 pm #306291Steven Zahm
Keymaster@ Fabrice
you know, It would be really helpful to you if I would actually read better!
Here’s a link to the function you’re using:
https://github.com/Connections-Business-Directory/Connections/blob/8.1.3/includes/class.terms.php#L1022The phpDoc for the function starts here:
https://github.com/Connections-Business-Directory/Connections/blob/8.1.3/includes/class.terms.php#L883So my error, again, is providing you with the wrong way to use the function … it should be:
$terms = cnTerm::get( 'category', array( 'child_of' => 3 ) );
I wrote the code but I don’t actually use it, yet, and it’s been a couple months since I did write it, so I’m just forgetting how it works. It’s no excuse for the bad info I’m giving you but it is the reason. I apologize! And if I’m wrong again, hopefully the phpDoc I linked to will give you the answers you need assuming I have no errors in it.
10/07/2014 at 12:26 pm #306292Steven Zahm
Keymaster@ Fabrice
Oh the design reason behind requiring the need to define
category
is this rewrite should enable me to support custom taxonomies in the future just like WordPress does now.10/08/2014 at 12:30 pm #306390Fabrice Locher
ParticipantHey Steven! Now I get the correct categories, but all categories which are “child_of = x”. Is there some query to only display the selected categories from a user?
-
This reply was modified 7 years, 8 months ago by
Fabrice Locher.
10/08/2014 at 1:35 pm #306398Steven Zahm
Keymaster@ Fabrice
When you say user, do you mean the categories assigned to an entry?
This would work:
// Grab an instance of the Connections object. $instance = Connections_Directory(); $terms_r = $instance->term->getTermRelationships( $entry->getID() ); $terms = cnTerm::get( 'category', array( 'child_of' => 73 ) ); foreach ( $terms as $term ) { if ( ! in_array( $term->term_id, $terms_r ) ) continue; echo $term->name; }
-
This reply was modified 7 years, 8 months ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.