GWcode Categories Support

Page 1 of 6.  1 2 3 >  Last ›

Avatar for Adam

#1 By Adam @ February 15th, 2011 02:29 (81 months ago)

I was pointed to this plug in from this devot:ee plug in http://devot-ee.com/add-ons/ee2-child-categories/

I would like to do the following however I am not sure if your plug in will do what I need

When a user clicks a parent category link on the resulting page I need to automatically display a list of child categories based on the parent category page visited.

The plug in that suggested you also suggested that they could do this via a dynamic_detect_channel="my_channel" attribute however I was unable to get this functioning.

My URL format when visiting a parent category page is currently
example.com//index.php/tag/category/fastcars

Avatar for Leon Dijk

Author

#2 By Leon Dijk @ February 15th, 2011 19:13 (81 months ago)

Hi Adam,

Unfortunately, what you want is not possible with the gwcode_categories plugin. It does sound like a good feature though so I will look into it and see if it's something I can add to a new release.

If you need a solution fast, you may want to try something like this:

If you're on example.com/index.php/tag/category/fastcars for example, you first need to get the category id for that page.

You can use an extension such as this one:
http://loweblog.com/software/low-seg2cat/

or a plugin such as this one:
http://devot-ee.com/add-ons/category-id/

Let's use the low-seg2cat extension for this example.
With that extension you'll be able to get the category ID with the {segment_3_category_id} variable.

Now that we have the category ID for the current category, we can use it in a query to show all child categories for that category:

{exp:query sql="SELECT * FROM exp_categories WHERE parent_id='{segment_3_category_id}'"}
 <a href="{path="temp/category/{cat_url_title}"}">{cat_name}</a><br />
{/exp:query}

Let me know if that works!

Avatar for Adam

#3 By Adam @ February 17th, 2011 14:46 (81 months ago)

That worked great using the low-seg2cat option.
Thanks

Avatar for Kath

#4 By Kath @ February 17th, 2011 20:20 (81 months ago)

Leon, can gwcode_categories plugin do something similar to the {categories} tag pair (display the categories an entry belongs to) but OMIT a certain category group?

I just tried using the code from Example 1, and I do omit the group I want to, but I get all categories from the other groups and not only the specific categories from an entry.

FYI: Url doesn't have the categories in this case, so I can't use low2seg here. (It's for a gallery index and I have several entries on same page, either with a couple of categories)

Thanks a lot for your time,
K

Avatar for Leon Dijk

Author

#5 By Leon Dijk @ February 17th, 2011 20:45 (81 months ago)

Hi Kath,

Yes, you should be able to do that with gwcode_categories.

Here's some example code that should do what you want:

{exp:gwcode_categories entry_id="18" group_id="3|4"}
 <h1>{group_heading}{group_name}{/group_heading}</h1>
 {cat_name}
{/exp:gwcode_categories}

In this case, it will display the categories in a nested list for entry ID 18, but only the ones from category groups 3 and 4. It will also display the category group name in <h > tags. Let me know if that works! You could also use the parameter if you don't want a nested list of categories.

Cheers,
Leon

Avatar for Leon Dijk

Author

#6 By Leon Dijk @ February 17th, 2011 20:48 (81 months ago)

By the way, Kath, the entry_id can be dynamic of course, so you can wrap the entire code in between {exp:channel:entries}..{/exp:channel:entries} tags so it would look like this:

{exp:channel:entries}
 {exp:gwcode_categories entry_id="{entry_id}" group_id="3|4"}
  <h1>{group_heading}{group_name}{/group_heading}</h1>
  {cat_name}
 {/exp:gwcode_categories}
{/exp:channel:entries}
Avatar for Adam Procter

#7 By Adam Procter @ February 24th, 2011 18:47 (80 months ago)

Leon, Thanks again, I was hoping you could point me in the right direction.
the lowseg2cat worked great

however I was wondering if it would also be possible to create a ‘back' button to go back to the parent of the child category you are looking at ?
Thanks

Avatar for Leon Dijk

Author

#8 By Leon Dijk @ February 24th, 2011 19:19 (80 months ago)

No problem Adam. You can try this code on the child category page:

{exp:query sql="SELECT * FROM exp_categories WHERE cat_id IN (SELECT parent_id FROM exp_categories WHERE cat_id='{segment_3_category_id}') LIMIT 1"}
 <a href="{path="tag/category/{cat_url_title}"}">Back to {cat_name}</a><br />
{/exp:query}

It should list the child's parent category. Hope that helps!
Leon

Avatar for Adam

#9 By Adam @ February 24th, 2011 19:43 (80 months ago)

Thank you very much worked :D

Avatar for Leon Dijk

Author

#10 By Leon Dijk @ February 24th, 2011 19:45 (80 months ago)

Excellent, good to hear!

Avatar for Bransin

#11 By Bransin @ February 25th, 2011 18:48 (80 months ago)

Great plugin. Would be great if it offered a show_empty parameter that works when specifying both channel and group_id.


if(!empty($this->channel) && !empty($this->group_id)) {
   // providing both channel and group_id wouldn't make sense
   return false;
}
Avatar for Leon Dijk

Author

#12 By Leon Dijk @ February 25th, 2011 20:40 (80 months ago)

Hi Bransin,

I'll add that to the next release, will hopefully wrap it up this weekend. Thanks for the feature request!

Avatar for Leon Dijk

Author

#13 By Leon Dijk @ February 26th, 2011 20:45 (80 months ago)

Bransin, would you be interested in testing the new version of the plugin before I release it officially? It has the show_empty parameter..and I should be able to have it finished by tomorrow. Let me know, you can send me an email by using the contact form. Thanks!

Avatar for Kath

#14 By Kath @ February 28th, 2011 19:41 (80 months ago)

Leon, thanks a lot for your reply, it works smoothly!
- K

PS. Unfortunately the comment notifications got in my spam box, so I didn't see your post until now.

Avatar for Leon Dijk

Author

#15 By Leon Dijk @ February 28th, 2011 19:47 (80 months ago)

Great! I'm working on improving the documentation and examples so it will be easier to understand what exactly can be achieved. Good to hear it's working smoothly!

Avatar for Leon Dijk

Author

#16 By Leon Dijk @ March 06th, 2011 20:11 (80 months ago)

Bransin, version 1.1.0 has just been released and should do exactly what you want.

Avatar for Bransin

#17 By Bransin @ March 14th, 2011 20:25 (80 months ago)

Wow! Thanks a bunch Leon. You saved my life.

Avatar for Leon Dijk

Author

#18 By Leon Dijk @ March 14th, 2011 20:38 (80 months ago)

No problem, I hope it will be useful!

Avatar for Jorix

#19 By Jorix @ March 24th, 2011 10:54 (79 months ago)

Would it also be possible to construct a categories breadcrumbs path from a subsubcategory, all the way back up. Thus by taking the name or id of the subsubcategory and reversing the hierarchy?

CATEGORIES
—-
1. Toys (category)
1.1 Indoor toys (subcategory)
1.1.1 Soccer tables (subsubcategory)

Suppose you navigated to the "Soccer tables" (subsubcategory) and output a list of soccer tables. Would it be possible with GWCategories to get a breadcrumb path like this:

Home > Toys > Indoor Toys > Soccer tables

Avatar for Leon Dijk

#20 By Leon Dijk @ March 24th, 2011 20:15 (79 months ago)

Hi Jorix,

No, unfortunately that is not possible, it only works when you want to create a path like that for an entry: http://gwcode.com/add-ons/gwcode-categories/examples/example5

It requires a bit of a change to the plugin as it needs a cat_id or category_url_title parameter to work with. I'll look into it and let you know tomorrow if it's something I can add.

Cheers,
Leon

Avatar for Jared

#21 By Jared @ March 24th, 2011 20:32 (79 months ago)

Wondering if the following is possible with this plug-in:

I want to show a set of entries from a particular channel, and within each entry display all categories from the category group that is assigned to that channel. AND, I want to be able to style the categories that the entry is assigned to differently than those that the entry is not assigned to.

For example, I have a category group with categories A, B, C, D. I have an entry assigned to categories A and B. I want the entry to display showing categories A, B, C, and D, but with A and B having a different style than C and D.

Thanks!

Avatar for Leon Dijk

Author

#22 By Leon Dijk @ March 24th, 2011 20:49 (79 months ago)

Hi Jared,

You should be able to do that with GWcode CatMenu, a plugin I released about a week ago: http://gwcode.com/add-ons/gwcode-catmenu

The code would be very simple, something like this:

{exp:gwcode_catmenu entry_id="21"}
 {cat_name}
{/exp:gwcode_catmenu}

Let's say that entry_id 21 has been added to categories A and B, which belong to a category group with categories A, B, C and D. The plugin will generate an unordered list with all 4 categories, but only A and B will have an "active" CSS class, which you can use for styling.

Will that work for you?

Avatar for Jared

#23 By Jared @ March 24th, 2011 22:05 (79 months ago)

Worked perfectly! Thanks for the prompt reply!

Note: It took me a while before I realized I had to include the site_id parameter (I've got a multi-site setup).

Thanks again!

Avatar for Leon Dijk

Author

#24 By Leon Dijk @ March 24th, 2011 22:47 (79 months ago)

Ah yes, by default it uses site ID 1. Didn't know you were using MSM :) Glad you figured it out and got it working! Nice to see how a plugin can be used in different ways :)

Avatar for Adam

#25 By Adam @ March 25th, 2011 00:59 (79 months ago)

Like your new plugin nice features ;)  if I do update the site i used some of you code help on here - http://www.dave-gibbons.com I'll use your new plug in instead of lowseg

Avatar for Leon Dijk

Author

#26 By Leon Dijk @ March 25th, 2011 08:11 (79 months ago)

Thanks Adam. Yes, you could definitely use GWcode CatMenu instead of the lowseg/exp:query solution. In fact, I used your question as a quote on the Overview page of GWcode CatMenu :) If you run into any problems while converting to that plugin, let me know!

Avatar for Ciaran Mc Donnell

#27 By Ciaran Mc Donnell @ April 12th, 2011 08:58 (79 months ago)

Hi

I am really stuck on an issue i have and I am not sure if your pluggin can handle this (fingers crossed) 
Scenario:  I have 3 groups.
Group 1,Group 2,Group 3. An entry will be assigned to a category within each group. On the front end i have 3 dropdowns.
When a user selects an option in the group 1 dropdown I want the second dropdown (group 2) to be populated with categories from group 2 where the entries are assigned to that option in group 1 and 2. And the same for group 3. 
So when a user submits the form after selecting options in the 3 dropdowns it will display a list of entries where they have categories selected in all 3 groups.

So i need to populate the 2nd and 3rd dropdowns with categories relating to entries that exist in previous dropdowns

I am populating the dropdowns from the segment section of the url to populate the 2nd and 3rd dropdowns


Hopefully this makes sense
I have tried everything and I can get this to work even using the query tag. Any help would be greatly appreciated

Thanks

Avatar for Leon Dijk

Author

#28 By Leon Dijk @ April 12th, 2011 15:08 (79 months ago)

Hi Ciaran,

The plugin can't do that on its own as your problem is quite unique and probably requires you to use some jquery/ajax and some queries to dynamically populate the 3 dropdown boxes. It may be able to help solve the problem, but it definitely can't handle it on its own.

I'll see if I can come up with an example that you can work with. I have your email address since you also submitted the contact form, so if I have something to show you I'll let you know.

Avatar for Ciaran Mc Donnell

#29 By Ciaran Mc Donnell @ April 12th, 2011 15:28 (79 months ago)

Thanks for the quick response

I have ajax set up to automatically populate the 2nd and 3rd dropdown's. So when a use selects the first drowdown a request is sent off with the value in the url and then the values are returned for second dropdown and the same for the 3 but 2 segments are passed. What i cant figure out is how to get the correct related categories to entries.

1 First dropdown is selected and via ajax sent to another page (using hopefully your module) that then gets the values for the second dropdown. The categories returned are values that have entries related to those categories in dropdown one 2.

the same process for for the 3rd drop down but 2 values passed.

So its done in 2 steps really. I will be passing urls to 2 separate files dpending on what dropdown is selected. If you have an example of this with out the ajax that would be brilliant

Avatar for Leon Dijk

Author

#30 By Leon Dijk @ April 12th, 2011 19:02 (79 months ago)

Hi Ciaran,

So you have successfully populated the 3 dropdown boxes with the correct categories.
Let's say that in your first dropdown, "Cat 1A" is selected, which has category ID 1.
In your second dropdown, "Cat 2A" is selected, which has category ID 2.

Both of those category ID's are being sent to an EE template with ajax, like so:
http://domain.com/template_group/template/1/2

In that template, you should then be able to use a query such as this to get all entries that are posted in both Cat 1A and Cat 2A:

SELECT ct.* FROM exp_category_posts cp, exp_channel_titles ct WHERE cat_id IN ({segment_3},{segment_4}) AND ct.entry_id=cp.entry_id GROUP BY entry_id HAVING COUNT(*) = 2

Does that help at all? For the 3rd dropdown box, you should be able to do the same thing, with a slightly different SQL query.

Either way, my plugin won't help with that, since you need a list of entries based on 1 or more categories, which is not something that the plugin is capable of at this time.

Avatar for Leon Dijk

Author

#31 By Leon Dijk @ April 12th, 2011 19:35 (79 months ago)

Reading your comments again, I think I misunderstood, you're still looking to select the correct categories in the 2nd and 3rd dropdown? I should be able to do that using jquery/ajax and custom queries, but it will take quite some time to set it up. The query in my post above will help you to get the list of entries based on what is selected in the dropdowns, but that is only helpful for the the very last step..

Avatar for Ciaran Mc Donnell

#32 By Ciaran Mc Donnell @ April 13th, 2011 09:11 (79 months ago)

Thanks leon

I thought this might be alot easier that it is using parameters like "has entries" etc to check if entries exists realting to the categories.I just cant find a solution to pass in category ids from different groups
Just to clarify:


Group 1
G1_Cat1
G1_Cat2

Group 2
G2_Cat1
G2_Cat2

Group 3
G3_Cat1
G3_Cat2
G3_Cat3

I have an entry that is assgined to

G1_Cat1,G2_Cat2,G3_Cat3


1:When i select G1_Cat1 in my first drodown send the request to an action page it needs to return the value G2_Cat2 for my second dropdown. So it knows that there is an entry related to both G1_Cat1 and G2_Cat2 but they are in differnet groups
2:When I select the returned value G2_Cat2 from my second drowpdown it should return the value of G3_Cat3 tot eh 3rd dropdown. So it knows that there is an entry related to G1_Cat1,G2_Cat2,G3_Cat3.
3:I am then using the Solspaces super search which returns the values from the 3 category dropdowns (i think).

The ajax is fine I have embeds (embed_group2, embed_group3) which returns the dropdown values for me but i dont know how to get the correct categories returned.

Any help or if you could point me in the right direction it would be greatly be apperciated

Avatar for Leon Dijk

Author

#33 By Leon Dijk @ April 13th, 2011 20:21 (79 months ago)

Hi Ciaran, I've sent you an email.

Avatar for Nuno Albuquerque

#34 By Nuno Albuquerque @ April 15th, 2011 04:18 (79 months ago)

Great addon and very efficient! Does it or will it ever support category custom fields?

Avatar for Leon Dijk

Author

#35 By Leon Dijk @ April 16th, 2011 00:25 (79 months ago)

Thanks Nuno! Currently it doesn't support category custom fields, but I'm working on a new version which has some very nice features. I'll try to add custom fields to that as well!

Avatar for Leon Dijk

Author

#36 By Leon Dijk @ May 01st, 2011 20:14 (78 months ago)

Hi Jorix (post #19),

I know it's a bit late and you may never read this message, but I just wanted to let you know that it's now possible to display child categories, exactly like you needed.

You can see an example here: http://gwcode.com/add-ons/gwcode-categories/examples/example9

Avatar for Alex Kendrick

#37 By Alex Kendrick @ May 04th, 2011 21:24 (78 months ago)

This is a really useful plugin, thank you very much for sharing it.

I noticed that when an author sets a categorized entry with a future entry date that the plugin will count that entry in the category count. Is there any way to exclude future entries from being counted? Something like the show_future_entries="no" parameter? If not, would you consider adding it in?

Avatar for Leon Dijk

Author

#38 By Leon Dijk @ May 04th, 2011 22:09 (78 months ago)

Thanks Alex!

You're right, it doesn't look at the entry dates currently. Probably shouldn't be a problem though, adding a show_future_entries parameter. I'll look into it tomorrow!

@Nuno (post #34), forgot to mention here that custom category fields are now supported.

Avatar for Alex Kendrick

#39 By Alex Kendrick @ May 05th, 2011 02:29 (78 months ago)

Thanks, Leon!

Avatar for Jay

#40 By Jay @ May 05th, 2011 15:07 (78 months ago)

Unfortunately it seems the "show_trial" parameter isn't working properly.

The following works:

{exp:gwcode_categories cat_id="54" style="linear" incl_self="no"}
<p>{cat_name}</p>
{/exp:gwcode_categories}

When I add the extra parameter, then nothing is output:

{exp:gwcode_categories cat_id="54" style="linear" incl_self="no" show_trail="yes"}
<p>{cat_name}</p>
{/exp:gwcode_categories}

Avatar for Leon Dijk

#41 By Leon Dijk @ May 05th, 2011 17:05 (78 months ago)

Hi Jay,

What version of the plugin are you using? The show_trail parameter has been added since version 1.2.0.

If you are using version 1.2.0, could you send me a screenshot of your category tree (Admin > Channel Administration > Categories > Add/Edit Categories)?

I've just tested your code and it works fine here..

Avatar for Jay

#42 By Jay @ May 05th, 2011 17:35 (78 months ago)

Hi Leon.

Thanks for replying so quickly. Here is a screenshot:

http://min.us/mvkB98e

I'm using 1.2.0 - I downloaded it a few hours ago.

I'm now using a URL segment to get the parent, so it's not critical to me.

Avatar for Leon Dijk

#43 By Leon Dijk @ May 05th, 2011 18:17 (78 months ago)

Hi Jay,

Looking at your screenshot, cat_id 54 is a root category. With the show_trail="yes" parameter, you're telling the plugin to show all parent categories for category id 54, but there are none, so it will not display anything. If you use cat_id 56 instead, you'll see that it will show the parent categories (only "Access Control" in this case).

Were you expecting it to do something else? If so, what are you trying to accomplish?

Avatar for Bransin

#44 By Bransin @ May 05th, 2011 22:27 (78 months ago)

Custom Category Fields don't seem to be working.

I have a custom field with the shortname of electronics_truncate. What outputs is exactly that with the curly brackets. Nothing parses.

The field type is a select list with only 2 options. "yes" and "no".

Avatar for Bransin

#45 By Bransin @ May 05th, 2011 22:29 (78 months ago)

Nevermind, I didn't realize there was a parameter to turn it on. Disregard

Avatar for Leon Dijk

Author

#46 By Leon Dijk @ May 05th, 2011 22:39 (78 months ago)

Great, glad you found the reason Bransin. I chose to not include custom category field by default because it requires an extra table lookup in the query. So to keep things as efficient as possible, they are only fetched and parsed when you tell it to.

Avatar for Jay

#47 By Jay @ May 06th, 2011 09:32 (78 months ago)

It looks like I didn't completely understand the "show_trail" parameter worked - I was thinking it would output the category of the subcategory, something like this:

Where 54 is a main category:

{exp:gwcode_categories cat_id="54" style="linear" incl_self="no" show_trail="yes"}
{cat_name}»
{/exp:gwcode_categories}

to output:

[category]ยป[subcategory]

Avatar for Leon Dijk

#48 By Leon Dijk @ May 06th, 2011 20:37 (78 months ago)

Hi Jay,

So you want to show a breadcrumb trail that looks like Access Control » Access Control Hardware right?

To do that, it's easiest if you have the category id for the Access Control Hardware category (which is normally the case if you want to show a breadcrumb trail for that category):

{exp:gwcode_categories cat_id="56" style="linear" show_trail="yes" backspace="7"}
 {cat_name} &raquo;
{/exp:gwcode_categories}

That way, you'll tell the plugin to show a trail from the root category for cat_id 56 to cat_id 56.

If you don't have the category id for the Access Control Hardware category, but you do have the category id for the Access Control category, it's still possible, but it will be more difficult because Access Control has several child categories and you only want to show one child category.

By using the cat_id="54" parameter, without using the show_trail parameter, you tell the plugin to show all child categories for the Access Control category. But, you can still exclude the other child categories from the output, so your code will look like this:

{exp:gwcode_categories cat_id="54" style="linear" backspace="7" excl_cat_id="55|57|58|59"}
 {cat_name} &raquo;
{/exp:gwcode_categories}

Your breadcrumb trail will then also look like this: Access Control » Access Control Hardware

Will any of this work for you? If not, maybe you can send me an email to discus this further?

Cheers,
Leon

Avatar for Leon Dijk

Author

#49 By Leon Dijk @ May 06th, 2011 21:21 (78 months ago)

Alex, version 1.3.0 has been released with two extra parameters, "count_future_entries" and "count_expired_entries". Should fix your problem!

Avatar for Alex Kendrick

#50 By Alex Kendrick @ May 06th, 2011 21:34 (78 months ago)

Leon, those new parameters are working perfectly. Thanks a ton!

Submit your comment

Sorry, comments are closed for this page.