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: 0.8.14, category, getCategory
- This topic has 2 replies, 2 voices, and was last updated 9 years, 4 months ago by
Steven Zahm.
-
AuthorPosts
-
08/01/2014 at 2:52 pm #299341
David Rogers
ParticipantMy category hierarchy is as follows:
Top
-Parent 1
–Child 1
–Child 2
–Child 3
-Parent 2
–Child 4
–Child 5
–Child 6How can I modify my template to only show the children of a single parent?
For example, I want to print out Child 1, Child 2, Child 3 on a single line, and then later in the template print out Child 4, Child 5, Child 6 on a separate line.
08/02/2014 at 6:20 pm #299442David Rogers
ParticipantA bit of an update, I’ve got the following code working, which shows the categories that are assigned to the individual:
<?php echo "<ul>"; foreach ( $entry->getCategory() as $category ) { if ($category->parent == '6') echo "<li>". $category->name . "</li>"; } echo "</ul>"; ?>
Is there some way to get all of the children of a parent category? And then highlight the ones that are assigned to an individual?
Example (if the individual is assigned child categories 2 and 3 but not 1 and 4):
o Child 1
x Child 2
x Child 3
o Child 4Basically, trying to show all the child categories and “check off” the ones that have been assigned.
-
This reply was modified 9 years, 4 months ago by
David Rogers.
08/04/2014 at 11:03 am #299501Steven Zahm
Keymaster@ David
This is a bit complex…
Probably the closest code example I can give is this:
https://github.com/Connections-Business-Directory/Connections/blob/0.8.14/includes/class.metabox-entry.php#L388That the code that creates the checklist in the admin.
The related function being used is here:
https://github.com/Connections-Business-Directory/Connections/blob/0.8.14/includes/class.form.php#L264And that calls a couple recursive functions for transversing the category tree and output the list.
It is come pretty old code that is going to be rewritten because it can be done better … but this should at least give you the idea of how to put this together. Hope it helps!
-
This reply was modified 9 years, 4 months ago by
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.