Categories/Sub-Categories with Classifieds

I know that this has been discussed here "ad-nauseum" because I've done the research yesterday/last night and read a boatload of posts about it. But, I was trying to set up a test classified website for my wife.

Maybe I'm a bit ambitious with what I'm thinking, but I was thinking I could have a top-level category of Clothes, and then sub-categories of Adult with sub-sub-categories of Male and Female. Of course, there would be other sub-categories of Clothes such as Teen, Children, and Baby probably (each having their own sub-sub-categories). Plus, there would be sub-categories of Clothes for things like accessories, handbags, maybe hats, or whatever (all those choices are up to her).

I figured that since CustomPress is now a part of Classifieds, I could follow the suggestion of @Mason in this thread (https://premium.wpmudev.org/forums/topic/custompress-subcategories-allowed#post-73326), but I put the category name in the category taxonomy and then when I put the subcategory name in the sub-category taxonomy, I can't choose the category name as the "Parent".

Bottom line of my question is, is this possible with the current version of Classified? Or do I just need to do a work-around for now until/if this feature is implemented? I could do this by just creating all the different variations in the master category list, but that just seems a bit clunky.

I also found a thread that had some code changes that could be made to accomplish this, but then FireFox decided to go wonky and I can't find the thread again. Who knows? Maybe I dreamed that solution.

Anyway, thanks in advance for any suggestions here. Links to posts/articles with potential solutions would be greatly appreciated.

James Dunn
Athens, GA USA

  • James Dunn

    Exactly @Timothy

    I originally tried to just do it all in the categories, but of course, that just lists them all as a vertical list when you try to put in the ad.

    Then, after reading the post referenced above, I created a secondary taxonomy called sub-categories (and planned for sub-sub-categories), but I couldn't set the parent category when entering the sub-categories (like Mason mentioned in his post).

    You can see what I'm talking about here: http://fbpageserver.com/classified/?page_id=6

    I was thinking it would be nice for the sub-categories to show based upon what is chosen in the category, but that may be beyond the scope of what can be done with the classified plugin in its current development state.

    Thanks Timothy for your your insight and thoughts. Like I said, this is just a test site right now on a subdomain. Once I figure it all out, I'll be moving this to a real domain so she can build this website out.

    James Dunn
    Athens, GA USA

  • James Dunn

    Hey @Timothy

    Here's a screenshot of the categories and sub-categories as I put them in the category listing (NOT creating a separate sub-category taxonomy). This just shows them as a list without differentiating the sub-categories of the main categories.

    Also, I think I forgot to mention, this is a fresh install on a sub-directory (not a subdomain as I originally stated), with minimal plugins installed (I think I only installed the Classifieds plugin), and WP 3.4.1 with Twenty Eleven theme activated.

    If you want admin access, I can set that up for you so you can see inside the back-end.

    James Dunn
    Athens, GA USA

  • Timothy Bowers

    Here's a screenshot of the categories and sub-categories as I put them in the category listing (NOT creating a separate sub-category taxonomy). This just shows them as a list without differentiating the sub-categories of the main categories.

    Perhaps I'm missing something here, but looking at your screenshot I see that Male and Female are a child of Adult and Adult is a child of Clothing.

    I then see that Girl and Boy are children of Child.

    Isn't that what you're looking for?

    Thanks.

  • James Dunn

    Hey @Timothy

    Yes, in the "listing" that I showed above, I was able to lay it out properly; however, when you go to the "Enter New Classified" page, the category/subcategory listing does not sort like that.

    As you'll note in the first attached image on this post, the categories don't group like in the image I posted above.

    So, I added a second taxonomy (we already have categories and tags) titled sub-categories. But, since it's in a separate taxonomy, I can't choose a category from the categories taxonomy as a parent - only ones that are in the sub-categories taxonomy.

    Is this just a styling issue or am I possibly doing something wrong?

    This may be an additional indication of the problem, but I tried to delete the Tags taxonomy and it will not delete. It will only move from the first one to the last one.

    Thanks in advance Tim.

    James Dunn
    Athens, GA USA

  • Mark Wallace

    Hello fella's

    I too had this problem, and is why i am hoping to use the new directory as a classifieds also.

    I had to do it like this if i wanted to use the current classifieds!

    Cloths
    Cloths Baby
    Cloths Baby Boy
    Cloths Baby girl

    Cloths Adult
    Cloths Adult Man
    Cloths Adult Woman

    Shoes
    Shoes Baby
    Shoes Baby Boy
    Shoes Baby girl

    Shoes Adult
    Shoes Adult Man
    Shoes Adult Woman

    This was as of the second week of June! I have not tried this plugin since; so there may have been a change.

    thanks Fella's

  • James Dunn

    Goodday @MTB1701 (Mark).

    I thought I had read a post from you about that. That was the only solution I could come up with - and not a very palatable one at that. CustomPress is supposed to do the subcategories according to Mason. I may actually install CustomPress somewhere else and see if I can do it there.

    I know I'm repeating what I read in the eleven dozen threads of people trying to do this, but this is a serious hole or failing of Classifieds. In print ads, it's not such a big deal, but on the internet, people are very accustomed to "drilling down" to find something - I know that I am.

    @Timothy, I'm trying to remember who the lead developer is on this - I saw him in another thread. Regardless, is this a quick question you could shoot his way?

    Thanks Mark and Tim. This thing has soooooo much promise, but I really don't want to end up having to do it the way Mark is doing it. Just seems like far too much confusion and headache. BTW, I installed a plugin to do categories and subcategories in the media panel and it suffers the same issue - even though I established a subcategory it doesn't really set itself up as a subcategory.

    James Dunn
    Athens, GA USA

  • Timothy Bowers

    @Timothy, I'm trying to remember who the lead developer is on this - I saw him in another thread. Regardless, is this a quick question you could shoot his way?

    It's Arnold. :slight_smile:

    I understand now, I think the problem will be if that they don't have any class to target it in CSS.

    So you could change that though, open:

    /wp-content/plugins/classifieds/ui-front/buddypress/members/single/classifieds/create-new.php

    Change:

    <table class="cf-terms">
    				<tr>
    					<?php foreach ( $this->taxonomy_objects as $taxonomy_name => $taxonomy_object ): ?>
    					<?php $terms = get_terms( $taxonomy_name, array( 'hide_empty' => 0 ) ); ?>
    					<td>
    						<select id="terms" name="terms[<?php echo $taxonomy_name; ?>][]" multiple="multiple">
    							<optgroup label="<?php echo $taxonomy_object->labels->name; ?>">
    								<?php foreach ( $terms as $term ): ?>
    								<option value="<?php echo $term->slug; ?>" <?php if ( isset( $_POST['terms'][$taxonomy_name] ) && is_array( $_POST['terms'][$taxonomy_name] ) && in_array( $term->slug, $_POST['terms'][$taxonomy_name] ) ) echo 'selected="selected"' ?>><?php echo $term->name; ?></option>
    								<?php endforeach; ?>
    							</optgroup>
    						</select>
    					</td>
    					<?php endforeach; ?>
    				</tr>
    			</table>

    To this:

    <table class="cf-terms">
    				<tr>
    					<?php foreach ( $this->taxonomy_objects as $taxonomy_name => $taxonomy_object ): ?>
    					<?php $terms = get_terms( $taxonomy_name, array( 'hide_empty' => 0, 'orderby' => 'term_group' ) ); ?>
    					<td>
    						<select id="terms" name="terms[<?php echo $taxonomy_name; ?>][]" multiple="multiple">
    							<optgroup label="<?php echo $taxonomy_object->labels->name; ?>">
    								<?php foreach ( $terms as $term ): ?>
    									<?php if ($parent = $term->parent) : ?>
    										<option value="<?php echo $term->slug; ?>" class="child" <?php if ( isset( $_POST['terms'][$taxonomy_name] ) && is_array( $_POST['terms'][$taxonomy_name] ) && in_array( $term->slug, $_POST['terms'][$taxonomy_name] ) ) echo 'selected="selected"' ?>><?php echo $term->name; ?></option>
    									<?php else : ?>
    										<option class="parent" value="<?php echo $term->slug; ?>" <?php if ( isset( $_POST['terms'][$taxonomy_name] ) && is_array( $_POST['terms'][$taxonomy_name] ) && in_array( $term->slug, $_POST['terms'][$taxonomy_name] ) ) echo 'selected="selected"' ?>><?php echo $term->name; ?></option>
    									<?php endif; ?>
    								<?php endforeach; ?>
    							</optgroup>
    						</select>
    					</td>
    					<?php endforeach; ?>
    				</tr>
    			</table>

    This will basically give the option a class of parent or child. It's currently only one deep though.

    Is this the sort of thing you're looking for to better style and indent that list? It's rough and untested but would be a start.

    Let me know, if this is in the right direct I could ask Arnold if he can include something similar in a future release.

  • James Dunn

    Hey @Timothy

    I'll give this a shot later today and let you know.

    I'm working on an article for wpmu.org this morning, writing a video script for a half dozen videos on a client's website, AND homeschooling my 5YO til lunch. Which project do you think is going to win out?

    Yep, the 5YO will definitely win my attention. Oh well. I'll take a look at this after lunch and put that code in there to see how it goes.

    Talk soon.

    James Dunn
    Athens, GA USA

  • James Dunn

    O.K> @Timothy

    I knew I couldn't set this aside til this afternoon.

    I added the code and then tried to put the CSS styling in. I guess I'm not 100% certain where you were adding the CSS styling. Did you create a default.css for the Classifieds plugin and put this CSS code in it? I tried it several places in the style.css for the theme, but that didn't work (much to my chagrin). Before I created a css for the classifieds I wanted to verify that you were thinking that.

    Thanks.

    James Dunn
    Athens, GA USA

  • Mark Wallace

    @JamesDunn

    I thought I had read a post from you about that. That was the only solution I could come up with - and not a very palatable one at that.

    Yes that post was my last encounter with the classifieds plugin. :slight_smile:

    Thanks Mark and Tim. This thing has soooooo much promise, but I really don't want to end up having to do it the way Mark is doing it.

    I'm Not! lol :slight_smile:

    I am waiting for the new directory release. I have found another classifieds plugin that will work as both a Directory/Classifieds, but i am hoping Arnold improves the directory plugin enough to use as both a directory and classifieds!

    Thanks Fella's

  • James Dunn

    DUH!!! What a big dummy I am. I didn't notice that you must be using BuddyPress on your test site and I'm NOT on my test site. The files you were noting were in the BuddyPress section and I guess I needed to edit a similar file in the General section.

    I'm editing page-my-classifieds.php - which appears to be the one that builds that page on a non-BuddyPress site. However, it is giving me an error that $this can't be used apparently. Here's the error:

    Fatal error: Using $this when not in object context in /home/jamesdun/wwwroot/fbpageserver.com/classified/wp-content/plugins/classifieds/ui-front/general/page-my-classifieds.php on line 333

    Is this a variable that you are using that is BP specific?

    Hate to keep bugging you Tim because I know this may be outside the scope of the Dev community. But, I also believe that if this is functional, then the Classifieds plugin is MUCH more valuable and more attractive to non-Dev members - hopefully attracting more new members.

    Take care Tim.

    James Dunn
    Athens, GA USA

  • Timothy Bowers

    Hate to keep bugging you Tim because I know this may be outside the scope of the Dev community. But, I also believe that if this is functional, then the Classifieds plugin is MUCH more valuable and more attractive to non-Dev members - hopefully attracting more new members.

    Don't worry about it.

    So, if you're not using BuddyPress you can find the code here:

    /classifieds/ui-front/general/page-my-classifieds.php Lines 225 and 337 This is for editing

    And:

    /classifieds/ui-front/buddypress/members/single/classifieds/edit-ad.php Line 56

    Take a look at what I did above, the principle is the same. So on line 225 your looking at this:

    <?php $terms = get_terms( $taxonomy_name, array( 'hide_empty' => 0 ) ); ?>
    									<td>
    										<select id="terms" name="terms[<?php echo $taxonomy_name; ?>][]" multiple="multiple">
    											<optgroup label="<?php echo $taxonomy_object->labels->name; ?>">
    												<?php foreach ( $terms as $term ): ?>
    												<option value="<?php echo $term->slug; ?>" <?php foreach ( $post_terms as $post_term ) { if ( $post_term->term_id == $term->term_id  ) echo 'selected="selected"'; } ?>><?php echo $term->name; ?></option>
    												<?php endforeach; ?>
    											</optgroup>
    										</select>
    									</td>
    									<?php endforeach; ?>

    It's pretty much the same thing, but if you continue to struggle then please do let me know.

    Take care.

  • aecnu

    Greetings JamesDunn,

    We have not heard back from you as to the status of this issue.

    If you are still having an issue please let us know so that we may try to get you fixed up as soon as possible by choosing to check mark this ticket as unresolved below and posting any new errors or symptoms you are noticing.

    This action will also bring your ticket up front back in plain view again within the ticket system.

    Thank you for being a WPMU Dev Community Member!

    Cheers, Joe

  • Mark Wallace

    I have finished my directory test and decided to move forward with it, i hope the same to be true with the classifieds beta as well.

    I must admit i was hopping JD's experaince would be way ahead of me on this, but from the email it sounds like you had ruff "charitable" week! :slight_smile:

    I will be testing it out no later than Monday!

    I got distracted searching for a solution to a project the past few days, but i found Arnolod a few test subjects to help. lol

    I have finished my directory test and decided to move forward with it, i hope the same to be true with the classifieds beta as well.

    Have a Great weekend fella's

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.