11

Resolved

Autoroute taxonomy token is always empty.

description

Please see

https://orchardtaxonomies.codeplex.com/workitem/61

Please note that despite the issue status of "resolved" this is NOT resolved as of Orchard 1.7 RC (2013-07-23).

comments

Trapulo wrote Aug 23, 2013 at 3:02 PM

Still the problem using final 1.7 today

BertrandLeRoy wrote Aug 23, 2013 at 8:08 PM

The bug is marked for 1.7.1. Did you try to reproduce with the latest in the 1.x branch?

Trapulo wrote Aug 26, 2013 at 9:53 AM

Sill same problem.
I've downloaded last code, copied it over my web dir, but nothing.

My autoroute configuration for Product content type is:
{Content.Fields.Product.Area}/{Content.Slug}
but url is created as "/Content.Slug" without the area part.

justrhysism wrote Aug 29, 2013 at 3:24 AM

I've been trying to dig into this, with the hope that it could be fixed without making changes to the Tokens module, but I'm not so sure it can be.

The EvaluateContext model isn't populated with the Terms for that Taxonomy (as Martin discovered on the original work item).

His "solution" works, but I'm not sure it's a real solution. I think this is going to require the brains of the Orchard Team to solve this puzzle...

justrhysism wrote Aug 30, 2013 at 12:55 AM

Digging further, it appears as though the LazyField, TermsField in the class TaxonomyField isn't loading the terms for the field.

I don't really understand how the LazyField actually works, but my understanding is that it "magically" loads things. I've used it before in writing modules, but I really have never actually understood how it works.

I could very well be completely off the mark; the taxonomies module is pretty sophisticated.

sebastienros wrote Oct 9, 2013 at 1:11 AM

Fixed in changeset 3aeed0ff0ff740b62d0fa8aae7ae44428bb90b1b

BreeeZe wrote Oct 9, 2013 at 4:56 PM

I applied your changes to the 1.7.1 to fix this problem specifically and it seems to work.. partially..
I added some taxonomies for a blog and if I created a new blogpost the taxonomy is now indeed part of the url created by autoroute however, when I turn on the option to auto regenerate the route and I update this post and republish it, the taxonomy part is gone again...

sebastienros wrote Oct 9, 2013 at 5:50 PM

Please try again now

BreeeZe wrote Oct 10, 2013 at 9:17 AM

Yep, that fixed it!
Thanks !

Piedone wrote Oct 11, 2013 at 9:35 PM

For people digging up this: keep in mind that you can't just use the filed token directly (e.g. {Content.Fields.BlogPost.Category}) as this tries to fetch the field's stored value - what TaxonomyFields don't have. You should add .Terms, e.g.: {Content.Fields.BlogPost.Category.Terms}.

sebastienros wrote Oct 11, 2013 at 10:41 PM

and to hget the first or only term, it's {Content.Fields.BlogPost.Category.Terms:0}, you can conclude on how to get the next ones

sheltonial wrote Oct 16, 2013 at 9:46 PM

Is there any way to generate a slug? When a taxonomy contains spaces they are transferred into the URL.

sebastienros wrote Oct 16, 2013 at 10:25 PM

I assume we are missing two tokens here:
  • one would return the taxonomy term it represents, which would let you to access the Slug
  • another one could be added to Text tokens to slugify the value
Can you open a bug for that and I will implement it ASAP

sheltonial wrote Oct 16, 2013 at 10:55 PM

Thanks for your quick response Sébastien.

I have implemented the following solution in my code: http://sheltonial.blogspot.com.au/2013/10/orchard-cms-taxonomy-term-autoroute.html

Also, created a new workitem for this: https://orchard.codeplex.com/workitem/20215

sebastienros wrote Oct 17, 2013 at 12:37 AM

you actually need to chain the indexed based token to the content item itself

sheltonial wrote Oct 18, 2013 at 4:29 AM

Righto, I haven't spent enough time in tokens to understand what the chaining actually does so I haven't touched that part, but I assume it's not a difficult change. Without chaining is working fine for my requirements.

Codinlab wrote Nov 7, 2013 at 2:33 PM

I tried with chaining, but it was not working for me. The exemple provided in TaxonomyTokens comments "{Content.Fields.Article.Categories.Terms:0.DisplayUrl}" failed.

Does someone successfully use it ?

sheltonial wrote Nov 11, 2013 at 12:10 AM

Since writing this I have discovered a better method which allows a full taxonomy term hierarchy path to be returning into a token in slug format. The code is provided here: http://sheltonial.blogspot.com.au/2013/11/orchard-cms-taxonomy-term-autoroute.html

Workitem https://orchard.codeplex.com/workitem/20215 has been updated too.