GWcode Categories Support

Page 2 of 6.  < 1 2 3 4 >  Last ›

Avatar for Jay

#1 By Jay @ May 09th, 2011 17:04 (87 months ago)

Thanks for your help - great support for a free plug-in!

Due to the other functionality of my site I opted to write a custom snippet to grab the the current URL and use the segment to create the breadcrumbs.

Thanks again.

Avatar for Paradise

#2 By Paradise @ May 10th, 2011 18:16 (87 months ago)

Hi,

i'm missing something. How can i show the first child only like "last_only" does it for the last child?

Depth does not work cause it does count from the very first category and not from the cat_id i'm pulling from my segment.

Avatar for Paradise

#3 By Paradise @ May 10th, 2011 20:27 (87 months ago)

Hm, and i have another problem.

count or results_total does not give back 0 (zero). So how can i do


{exp:gwcode_categories cat_id="{segment_2_category_id}" style="simple" incl_self="no"}
  {if "{results_total}" >= "1"}
   show 1
  {if:else}
   show 2
  {/if}
{/exp:gwcode_categories}

"show 2" does not show. I need the incl_self="no".

Also tried other ways like:

{if "{results_total}" == "0"}

{if "{results_total}" == ""}

Avatar for Leon Dijk

Author

#4 By Leon Dijk @ May 10th, 2011 20:50 (87 months ago)

Hi Bjorn,

First question:
Adding a "first_only" parameter would do the job, but then again, it's a bit specific and then I would also have to add a "second_only" parameter etc.

What if I created a new variable called "{output_depth}" so you'll be able to do something like this:

{exp:gwcode_categories cat_id="{segment_2_category_id}" style="simple" incl_self="no"}
 {if "{output_depth}" == 1}
  Show something..
 {if:elseif "{output_depth}" == 2}
  Show something else
 {if:else}
  The rest..
 {/if}
{/exp:gwcode_categories}

Would that work? If so, I can add that in if you want.

Question two:
Have you tried this?
{if no_results}show something{/if}

Avatar for Paradise

#5 By Paradise @ May 10th, 2011 22:22 (87 months ago)

Saw the no_results 15 minutes after my post here. First i was trying:

{exp:gwcode_categories cat_id="{segment_2_category_id}" style="simple" incl_self="no"}
  {if no_results}
  show 1
  {if:else}
  show 2
  {/if}
{/exp:gwcode_categories}

but that does not work. This works:

{exp:gwcode_categories cat_id="{segment_2_category_id}" style="simple" incl_self="no"}
  {if no_results}
  show 1
  {/if}
  show 2
{/exp:gwcode_categories}


The problem with the output_depth is that you need to know the depth and have to make for for everything an if condition.

Another way maybe would be something like "if_theres_a_child".

  {if if_theres_a_child}
  {cat_name}
  {if:else}
  something
  {/if}

Avatar for Paradise

#6 By Paradise @ May 10th, 2011 22:31 (87 months ago)

Ups sorry. The if_theres_a_child thing would be a solution (another way) for the no_results thing.

With this thinking around 1000 corner's i sometimes get confused.

Avatar for Ryan

#7 By Ryan @ May 11th, 2011 21:03 (87 months ago)

Hi Leon,

Awesome, awesome stuff. Your plugin has allowed me to create nested categories in a way I hadn't thought possible with EE.

Question for you: I've reviewed the docs and parameters, and while you can display categories with entry counts next to them, it doesn't look like it's possible to create a list of categories sorted by entry counts.

My goal is to create a "popular categories" list—can this be done with your plugin?

Avatar for Leon Dijk

Author

#8 By Leon Dijk @ May 11th, 2011 21:56 (87 months ago)

Thanks Ryan! Always nice to read those things :) Would you mind if I used your first sentence as a testimonial?

I haven't created a sort/order_by parameter yet, but it's definitely something I can look into. I'll probably release a new version in 2 days so I'll try to add your request as well.

Avatar for Ryan

#9 By Ryan @ May 11th, 2011 22:07 (87 months ago)

Sure, go ahead and use that as a testimonial.

If you added that in 2 days I'd be ecstatic. Thanks; I'll keep my ear to the ground on this one.

Another item I'm struggling with right now, via the exp:query module, is trying to pull the newest X categories (by ID) and then sort them by name (a "Newest Categories" list, if you will). Another idea for a future release ;)

Avatar for Leon Dijk

Author

#10 By Leon Dijk @ May 11th, 2011 22:18 (87 months ago)

Great thanks! Sure, if I manage to sort by entry count, I may as well add sorting by id as well. I'll keep you posted.

Avatar for Bransin

#11 By Bransin @ May 13th, 2011 21:59 (86 months ago)

When viewing the output debugging and total execution time, I'm finding that this plugin nearly adds an entire second where normally most of my queries are 0.0008.

0.7413   SELECT c.parent_id, c.cat_name, cat_url_title, cat_description, cat_image, cat_order, COUNT(cp.entry_id) AS entry_count, cfd.* FROM exp_categories c LEFT JOIN exp_category_posts as cp ON c.cat_id=cp.cat_id LEFT JOIN exp_category_field_data cfd ON cfd.cat_id=c.cat_id WHERE c.site_id=cfd.site_id AND c.group_id IN (5) AND c.site_id IN (1) GROUP BY c.cat_id ORDER BY site_id, FIELD(c.group_id, 5), parent_id, cat_order

Avatar for Leon Dijk

Author

#12 By Leon Dijk @ May 13th, 2011 22:06 (86 months ago)

Hi Bransin,

Using the same query, here are my results:
Showing rows 0 - 7 (8 total, Query took 0.0063 sec)

Do you have a large set of custom category fields? How many rows are being returned?

Avatar for Leon Dijk

Author

#13 By Leon Dijk @ May 13th, 2011 23:47 (86 months ago)

Ryan,

I have a new version ready that's capable of ordering by entry count, to create a "popular categories" list. It's also possible to order by category id, to create a "Newest Categories" list. Plus, I've added the ability to order by category name. And, you can make some combinations as well, for example, order by entry count and category name (categories with the same entry count will then be ordered by name).

You can also limit those results with the limit parameter.

However, it seems I can't integrate this: "newest X categories (by ID) and then sort them by name", as it requires sorting by ID first, then only use X results and then sorting them again, by name. In the plugin, the "use X results" part (limit parameter) occurs at the very end, which is the reason why I can't implement that specific feature.

I still think it's possible though without too much trouble, but it's not something I'm going to create for this release. If you want I can see if I can create a custom version just for you though.

Anyway, I need another day to fully test this new release and write documentation etc. I'll keep you posted.

Avatar for Leon Dijk

Author

#14 By Leon Dijk @ May 13th, 2011 23:50 (86 months ago)

General information - If anyone read the posts by Paradise on these support pages and wondered if there was a solution for it, here it is: http://expressionengine.com/forums/viewthread/188454/

Avatar for Leon Dijk

Author

#15 By Leon Dijk @ May 14th, 2011 11:32 (86 months ago)

Hi again Ryan,

Just wanted to let you know that I've uploaded v1.4.0. I have yet to write documentation for it and release it officially, but since I don't have time for that today, I decided to upload it anyway so you can give it a go.

It has the new parameters "orderby" and "sort".
To get the popular categories list, you would use orderby="entry_count" sort="desc"

If you also want to sort the categories with the same entry count by name, you would use this: orderby="entry_count|cat_name" sort="desc|asc"

To get the newest x categories, use something like this: orderby="cat_id" sort="desc" limit="5"

I hope you're getting the results you're looking for. If you want me to look at your "newest X categories and then sort them by name" problem, let me know!

Cheers,
Leon

Avatar for Bransin

#16 By Bransin @ May 14th, 2011 17:22 (86 months ago)

Hey Leon,

My query returned (117 total, Query took 0.7349 sec). There is only 1 custom category field.

I tried the query without the calling the additional custom fields, removed category_image, category_description and was able to bring it down to 0.5655 seconds.

Not sure if there is anything else that could be done to get that lower since it's so many results. Maybe EE tag caching is the best solution to so many results?

Avatar for Leon Dijk

Author

#17 By Leon Dijk @ May 15th, 2011 20:49 (86 months ago)

Hi Bransin,

Could you try this query and let me know how fast it is?

SELECT c.parent_id, c.cat_name, cat_url_title, cat_description, cat_image, cat_order, COUNT(cp.entry_id) AS entry_count, cfd.* FROM exp_categories c LEFT JOIN exp_category_posts as cp ON c.cat_id=cp.cat_id LEFT JOIN exp_category_field_data cfd ON cfd.cat_id=c.cat_id WHERE c.group_id IN (5) GROUP BY c.cat_id ORDER BY c.group_id, parent_id, cat_order

I've removed references to site_id (only needed for MSM, which you might not use) and I've simplified the sorting a bit. I don't expect miracles though, so yes, caching may be a good solution. Maybe you can create a new template specifically for the plugin, cache that template and then embed it in the other template?

Avatar for Bransin

#18 By Bransin @ May 15th, 2011 21:10 (86 months ago)

Results, (117 total, Query took 0.6082 sec)

Definitely helps a little yet site_id would be important for MSM support. I'm just shocked that even 117 rows would take half a second. My expectations are perhaps too high in this age.

I'm going to do the tag caching. I'm passing embed variables to the plugin parameters so template caching wouldn't quite work in this situation.

Thanks for your help Leon and a great plugin. Great support.

Avatar for Leon Dijk

Author

#19 By Leon Dijk @ May 15th, 2011 21:28 (86 months ago)

I don't think your expectations are too high, I would certainly think a query like that with 117 results would be quicker as well.

I'm in the process of moving my stuff to a new pc, but once I'm all set I'm going to add a whole bunch of categories and custom fields to see what results I'm getting. But yes, tag caching sounds like a good idea in this case.

Thanks for the feedback Bransin!

Avatar for Bransin

#20 By Bransin @ May 16th, 2011 02:20 (86 months ago)

During the process of figuring out how to optimize the SQL query, it would be awesome if your plugin had a performance mode parameter.

This would return the basic site_id, cat_name, cat_url, cat_parent, and chosen category custom fields by pipe characters.

Just an idea, thanks!

Avatar for Bransin

#21 By Bransin @ May 16th, 2011 18:33 (86 months ago)

Hey Leon, problem resolved.

There is conflicting logic. When I specify parameter show_empty="no" and entry_count="no", the SQL query is still counting all entries for the category. If I remove show_empty parameter, the entry_count parameter then works.

I didn't need the entry_count feature, so this brought the time down drastically to .0061

Avatar for Leon Dijk

Author

#22 By Leon Dijk @ May 16th, 2011 19:13 (86 months ago)

Hi Bransin,

Ah yes, I thought you needed the entry_count :)

If you have a lot of categories and entries, it will definitely take some extra time to calculate the entry_count for each category (so caching may be unavoidable).

Right now, when you use show_empty="no", it basically sets the entry_count parameter to "yes", counts the entries for each category and then removes the ones with 0 entries. I've created it like that because I've always assumed people wanted to use the entry_count variable when they've set the show_empty="no" parameter. But, as you pointed out, that may not always be the case. Thanks for bringing this up Bransin, I'll look into it for a future release. Glad you're all set now!

Avatar for Aaron

#23 By Aaron @ May 17th, 2011 14:40 (86 months ago)

Leon,

I have a category setup like so:

- Sports
- - Basketball
- - - NBA
- - - College

Is there anyway to generate URLs like:
/sports/basketball/college

This would be MASSIVELY helpful. Thanks!

Avatar for Leon Dijk

Author

#24 By Leon Dijk @ May 17th, 2011 16:01 (86 months ago)

Hi Aaron,

To do that, you need the category ID for the last category (College):

<a href="/{exp:gwcode_categories cat_id="25" show_trail="yes" style="linear" backspace="1"}{cat_url_title}/{/exp:gwcode_categories}">Link text</a>

It will then create a path from the root category to the College category. Does that work for you?

Avatar for Aaron

#25 By Aaron @ May 17th, 2011 16:17 (86 months ago)

Leon,

I'm not sure if that will work for my particular need, unfortunately. I'm listing all child categories of the current page being viewed (/sports). So I'm generating all the relevant categories using:


{exp:gwcode_categories cat_id="{segment_1_category_id}" entry_count="yes" show_empty="no"}
 <a href="{cat_url_title}">{cat_name} ({entry_count})</a>
{/exp:gwcode_categories}

This prints out all the categories and looks perfect, but the {url_titles} do not show any hierarchy. Instead, they all simply state /football, /basketball, /nba, etc.

Does that make sense?

Avatar for Aaron

#26 By Aaron @ May 17th, 2011 16:18 (86 months ago)

Leon,

Sorry, the anchor was parsed in that last comment but I have an anchor tag around the {cat_name} and {entry_count}

Thanks!

Avatar for Leon Dijk

Author

#27 By Leon Dijk @ May 17th, 2011 17:09 (86 months ago)

Ah yes, I see what you mean. I have a new version in the works with another feature request, so I might as well look into this as well before I release it.

PS. I fixed the code in your comment and changed your name to Aaron in those last 2 comments, I hope that's ok (you entered Leon as your name by accident I assume) :)

Avatar for Aaron

#28 By Aaron @ May 17th, 2011 18:07 (86 months ago)

Haha, I think you're right! Sorry, I like to live vicariously through others. :)

That would be amazing if that is no trouble. I'm working on a site where this is a big part of it, so hopefully you can work your magic into it. Thanks for your help!

Avatar for Leon Dijk

Author

#29 By Leon Dijk @ May 17th, 2011 20:09 (86 months ago)

LOL :) I've released version 1.5.0 Aaron, you can download it from the site. The new variable: {complete_path}

Let me know if that works for you!

Avatar for Aaron

#30 By Aaron @ May 17th, 2011 20:26 (86 months ago)

PERFECT! This works awesome, Leon! Thanks a ton for the fantastic support and a brilliant add-on. This is really the way EE categories should be.

Avatar for Leon Dijk

Author

#31 By Leon Dijk @ May 17th, 2011 21:05 (86 months ago)

Thanks for the compliments Aaron! And the twitter shout out as well ;) Glad you have everything working now!

Avatar for Brett

#32 By Brett @ May 26th, 2011 03:05 (86 months ago)

Hi Leon,

I'm running into a problem with the Categories plugin using the group_id parameter. I have a Channel with 3 Category Groups assigned to it. I want to output a list for the categories in just one group.

However, using this code:


{exp:gwcode_categories
channel="artwork"
group_id="1"
entry_count="yes"
}
<a href="{path="artwork"}/{cat_url_title}">{cat_name}</a> ({entry_count})
{/exp:gwcode_categories}

I get the structure that I want, but the tag outputs all 3 Category Groups. Basically it seems to ignore the group_id="1" parameter.

Any ideas?

Thanks!

Avatar for Brett

#33 By Brett @ May 26th, 2011 03:36 (86 months ago)

Hi Leon,

Please ignore my previous post! I figured it out after reading through the docs a little more closely—removing the channel="artwork" parameter fixed it.

B.

Avatar for Leon Dijk

Author

#34 By Leon Dijk @ May 26th, 2011 13:38 (86 months ago)

Hi Brett,

Yep, that does the trick. By using both the channel and group_id parameter, you're telling the plugin to grab all categories for the channel AND the categories from the category groups in the group_id parameter. Glad you figured it out!

Avatar for Brett

#35 By Brett @ May 26th, 2011 14:00 (86 months ago)

Hi Leon,

Hoping you (and your excellent plugin) can help ...

I've got something of an edge-case for a project I'm working on. GW Categories can output the categories (and category groups) that a single entry has been added to. Is there any way to get it to output a combined, "digest" version of the categories that multiple entries belong to?

I know the tag will loop over multiple entries, and output a list of categories and category groups for each—but can they be output all together?

For example, if I have two entries with categories as follows:

Entry 1
—category 1
—category 3

Entry 2
—category 2
—category 4

Could the categories tag be used something like this:


 {exp:gwcode_categories entry_id="1|2" style="linear" backspace="1"}
        {cat_name},
 {/exp:gwcode_categories}

to output a single combined list, like this:

Entries 1 & 2
category 1, category 2, category 3, category 4.

Basically I just need to show any categories that a bunch of entries belong to. In this case, I don't need to show which specific entries belong to which particular categories.

Does that make sense?

Cheers,

Brett

Avatar for Leon Dijk

Author

#36 By Leon Dijk @ May 26th, 2011 20:58 (86 months ago)

Hi Brett,

Thanks for the detailed description of your problem. I see what you mean. Currently, it's not possible to use more than 1 value for the entry_id parameter, because I wasn't sure what the output should looks like when you're using it in combination with the show_full_trail parameter for example.

I'll have a look at the code to see if it's something I can add. I'll keep you posted!

Avatar for Leon Dijk

Author

#37 By Leon Dijk @ May 27th, 2011 20:58 (86 months ago)

Hi again Brett,

I'm almost done adding this feature. I think it works as expected, but I still need to do some thorough testing before I release it. If you need it this weekend let me know and I'll send you a link to the beta so you can see for yourself how it works.

Cheers,
Leon

Avatar for Brett

#38 By Brett @ May 28th, 2011 00:32 (86 months ago)

Hi Leon,

Fantastic! Many thanks.

Yes I'd love to get my hands on it this weekend. I'm due to show the client a prototype of the site early next week, so adding this capability helps to round it out nicely.

Cheers,

Brett

Avatar for Leon Dijk

Author

#39 By Leon Dijk @ May 28th, 2011 11:21 (86 months ago)

Hi Brett,

Here you go, give it a try and let me know how it works!
http://dl.dropbox.com/u/16628132/gwcode_categories_1.6.1.zip

Out of curiosity, how are you providing the entry_id parameter value such as "1|2|3"? Do you enter it into the template as fixed, or are you generating it with PHP enabled for example?

Avatar for Brett

#40 By Brett @ May 29th, 2011 15:05 (86 months ago)

Hi Leon,

Brilliant ... that does just what I need! Thank you!!

I'm feeding the pipe-delimited entry ids dynamically, using a Playa tag—{exp:playa:parent_ids}—(passed through an embed to get around some parsing issues).

I'm building a site for an art gallery. I have Artists and Artworks modelled as Channels. Artworks are related to Artists using a Playa field. Artworks also have a number of Categories assigned (such as Subject, Style, Media, etc.). I have a detail/bio page for each Artist, which lists their Artworks (using an {exp:playa:parents} tag), and a list of links for any/all of the Categories containing the Artists' combined works—which is where your tag comes in. So a site visitor can browse any of the categories in which an Artists' work is represented.

Sounds simple in principle, but another example of something that is impossible (or at least really hard!) using standard EE tags. One embed and three lines of template code using your plugin. Thanks again!

Cheers,

Brett

Avatar for Leon Dijk

Author

#41 By Leon Dijk @ May 29th, 2011 17:19 (86 months ago)

Hi Brett,

Great! Thanks for mentioning how it's being used! Sounds like you have created a nice structure/navigation there. Really interesting for me to read these things, what type of problem you're having and how the plugin has been able to help solve it. Just the fact that you're using it in combination with Playa..never tried that myself.

I'll probably release the 1.6.1 update later tonight or tomorrow. No need for you to update the files, I haven't changed anything else. Good luck with the project!

Cheers,
Leon

Avatar for Jae Barclay

#42 By Jae Barclay @ June 03rd, 2011 08:59 (86 months ago)

Hey Leon,

Great add-on! Thanks for making this available.

Just wanted to report a simple bug. If you have multiple category groups assigned, AND one of them happens to be the "None" option, the page will stop processing and be rendered blank.

In most cases devs will choose not have "None" option selected, but casual users or clients may.

Thanks again :)

Jae

Avatar for Leon Dijk

Author

#43 By Leon Dijk @ June 03rd, 2011 09:20 (86 months ago)

Hi Jae,

Ah yes, I see what you mean, thanks for reporting! Never tried that myself :)
That's probably an easy fix, I'll release an update later today or tomorrow.

Thanks again!
Leon

Avatar for Leon Dijk

Author

#44 By Leon Dijk @ June 03rd, 2011 09:21 (86 months ago)

Ah, just noticed the review over at Devot:ee, many thanks Jae! :)

Avatar for Jae Barclay

#45 By Jae Barclay @ June 03rd, 2011 11:15 (86 months ago)

Thanks Leon - absolutely my pleasure leaving the well-deserved comment! I am going to test out CatMenu next, and it would have been a time saver in doing http://www.sensorex.com site—we had to create a custom jQuery & PHP to pull the accordion, nested nav.

I'll be sure to mention it in our Creat-ee classes as well :)

Jae

Avatar for Leon Dijk

Author

#46 By Leon Dijk @ June 03rd, 2011 14:24 (86 months ago)

That would be awesome, I'd be honored to have it mention in your classes!

Both plugins are still relatively new with new features being added regularly. A new version for GWcode CatMenu will be released soon which will also support custom fields for example.

I've never used it to create a dynamic jQuery menu, but it has always been something I wanted to write a tutorial for as I'm sure it's possible.

If you ever find something that you think should/could be added to either one of the plugins, let me know!

Cheers,
Leon

Avatar for Jason Siffring

#47 By Jason Siffring @ June 24th, 2011 21:08 (85 months ago)

Do the {has_children} and {has_children_in_output} variables work? I can't seem to get them to output anything or fire on a conditional.

This code spits out the list of categories correctly, but it doesn't hit the "children" or "no children" conditional and doesn't output anything for {has_children} as I would expect from the docs.


{exp:gwcode_categories channel="best_buy" class="accordion" style="nested" entry_count="yes"}
  <br>{cat_name} {has_children}
 
  {if has_children_in_output}
  children
  {/if}
  {if !has_children_in_output}
  no children
  {/if}
{/exp:gwcode_categories}

Am I missing something obvious?

Avatar for Leon Dijk

Author

#48 By Leon Dijk @ June 24th, 2011 21:24 (85 months ago)

Hi Jason,

Are you using an older version of the plugin? I released v1.8.0 yesterday, which introduced the "has_children" and "has_children_in_output" variables.

Both variables return either true or false, so using this won't do anything:

{has_children}

You'll have to use them in conditionals such as:

{if has_children}..{/if}

Or, if you want to test if they are false:

{if has_children == FALSE}..{/if}

Let me know if that helps!

Avatar for Jason Siffring

#49 By Jason Siffring @ June 24th, 2011 21:30 (85 months ago)

Yeah, I just realized that's my problem. :)

Another developer had your plugin already installed and I was just going off your docs not realizing we were out of date.

Sorry about that. Nice plugin!

Avatar for Leon Dijk

Author

#50 By Leon Dijk @ June 24th, 2011 21:42 (85 months ago)

Thanks Jason! If you get stuck somewhere, let me know!

Submit your comment

Sorry, comments are closed for this page.