Open LMSSonos opened 4 years ago
/cc @jptissot
How can I slugify the Taxonomy path? By simply adding slug it will join the array and I lose the / in the path
I don't understand this one, can you share some details?
Sorry for not beeing clear. Let's assume I have the following Taxonomy for the Offers
Now, if I run for the Offer with the Taxonomy Sub the following code
{{ ContentItem.Content.Offer.OfferType.TermContentItemIds[0] | inherited_terms: ContentItem.Content.Offer.OfferType.TaxonomyContentItemId | reverse | join: "/" }}
I get the result "Main/Sub"
If I want to slugify the names for the url usage in autopath I added following rule
{{ ContentItem.Content.Offer.OfferType.TermContentItemIds[0] | inherited_terms: ContentItem.Content.Offer.OfferType.TaxonomyContentItemId | reverse | join: "/" | slugify }}
Now it returns me "main-sub". This is as expected but not as wanted, I wanted to get "main/sub"
so next try is to use as following
{{ ContentItem.Content.Offer.OfferType.TermContentItemIds[0] | inherited_terms: ContentItem.Content.Offer.OfferType.TaxonomyContentItemId | reverse | slugify | join: "/" }}
Now what happens it returns "mainsub". The slugify seems to join the array from reverse.
Maybe {{ ... | reverse | join: "/" | downcase }}
@jtkech thanks, your case works for my example, but if you have special characters you need slugify which does more than downcase
as example
then you want to generated main-a/sub-a
Since the taxonomy content type already have the alias part, and the alias part normally slugified from the content item when creating a taxonomy. So how about recursively get the alias by liquid map filter then reverse & join?
example:
{{ ContentItem.Content.LocalizationPart.Culture }}/{% if ContentItem.Content.Offer.OfferType.TermContentItemIds.size > 0 %}{{ ContentItem.Content.Offer.OfferType.TermContentItemIds.first | inherited_terms: ContentItem.Content.Offer.OfferType.TaxonomyContentItemId | map: "Content" | map: "AliasPart" | map: "Alias" | reverse | join: "/" }}/{% endif %}{{ ContentItem.DisplayText | slugify }}
New to orchard core, please correct me if I'm wrong.
does slugify work instead of downcase from @jtkech 's example?
I have issues/questions regarding autoroute and taxonomies. In my example I have a taxonomy field OfferType which is the Taxonomy field. In my case I also can only select a leave and it's mandatory. I have configured a pattern like following
{{ContentItem.Content.LocalizationPart.Culture}}/{{ ContentItem.Content.Offer.OfferType.TermContentItemIds[0] | inherited_terms: ContentItem.Content.Offer.OfferType.TaxonomyContentItemId | reverse | join: "/" }}/{{ ContentItem.DisplayText | slugify }}
This works as expected.
First questions: Is this the right way to do this? How can I slugify the Taxonomy path? By simply adding slug it will join the array and I lose the / in the path
Second quesiton: How do I localize the taxonomy values?