Parent Categories

This topic contains 4 replies, has 4 voices, and was last updated by  Stiofan O’Connor 8 years, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: ,

  • Author
    Posts
  • #233061

    Ray Scarpa
    Expired Member
    Post count: 84

    We are trying to restrict users from placing listings in Parent Categories, allowing those parents to act only as placeholders for the subcategories. Saw in another forum post that “Any listing in a subcategory needs to be in the parent category as well.” and wondering if that is still true? Each of our plans allow for users to select a limited number of categories, so having each listing appear (mandatory) in the parent category seems restrictive.

    We tried the option of excluding parent categories from each plan in admin, but only parents (not subcategories) can be excluded in the list, so assuming that also excludes their subcategories?

    Hoping you may have some suggestions about how to allow users to list only in the specific categories that are most relevant (Casual Dining or Pizza instead of the more generic “Restaurants”).

    Thanks!

    #233394

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    that is not possible I’m sorry.

    The parent category must always be selected too.

    Thanks

    #233691

    Rainer Lang
    Expired Member
    Post count: 33

    Hello,
    in our setup we use category hierarchy for a better structure, too, most entries are not linked to a parent category, but to subcategory only. On the map’s category list we need the total count for parent categories, including subcategories. So we changed the function geodir_filter_empty_terms() in geodirectory-functions/general_functions.php lines 4786-4798. Maybe you are interested in this code, too.

    Dear developers, we would be very glad if you implement this code into the next version. Otherwise could you please add a hook that we can modify it without hacking the code?

    
    
    
    function geodir_filter_empty_terms($terms) {
        if (empty($terms)) {
            return $terms;
        }
    
        $return = array();
        foreach ($terms as $term) {
            if (isset($term->count) && $term->count > 0) {
                $return[] = $term;
            } 
    	else if(!empty($term)) {
    		$count = 0;
    		$taxonomy = $term->taxonomy;
    		$args = array(
    			'child_of' => $term->term_id,
    		);
    		$tax_terms = get_terms($taxonomy,$args);
    		foreach ($tax_terms as $tax_term) {
    				if( $tax_term->count > 0) {
    					$return[] = $term;
    					break;
    				}
    		}
    
    	}
        }
        return $return;
    }
    
    

    Suggestion for a filter hook:

    
    
    ...
    	else if(!empty($term)) {
    		$return = apply_filters( 'geodir_filter_empty_terms_filter', $term);
    
    	}
    
    #234195

    Paolo
    Site Admin
    Post count: 31206

    Hi Rainer,

    I’ve reported your request to the developers. They won’t be able to add it to next release, because that will be probably released in the next few minutes.

    They will consider it for next release and they will let you know asap.

    Thanks

    #234824

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    I have added a filter so you can achieve what you want:
    https://github.com/GeoDirectory/geodirectory/commit/440de91ee89616c86bea5817f52863a19f03a96e

    Thanks,

    Stiofan

Viewing 5 posts - 1 through 5 (of 5 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount