Taxonomy Alternate Template for summary not being used

Topics: Customizing Orchard, Troubleshooting
Aug 30, 2012 at 7:42 AM

I'm using the taxonomy module, and I've defined a taxonomy called "Coffee Blends". Then in the resulting "Coffee Blends Term" content type that is dynamically generated, I have manually added the Body part.

This allows me to define some additional content for each term that I create in the Taxonomy.

When viewing the taxonomy, the terms are listed, with the body part being summarised (truncated) due to the default template Views/Parts.Common.Body.Summary.cshtml.

I wish to display the full body in the summary view for each term when viewing the page for the taxonomy, so I have specified an alternate template in my theme Views/Parts.Common.Body.Summary-Coffee-Blends.cshtml and placed @Model.Html in this template.

Now when I visit the page for the taxonomy, the Shape Tracing module indicates that the alternate template I defined is the active template, however the HTML that is output for this shape is still the summarised output (truncated by the default body summary template).

Is this a a bug, or is there something that I'm doing wrong in this case? Could it be something to do with the fact that the content type for the taxonomy terms has been dynamically generated?

Any input appreciated.

Coordinator
Sep 13, 2012 at 12:31 AM

What alternate is that? What's creating it?

Sep 13, 2012 at 2:09 AM

In the output of the Shape Tracing module, on the "Shape" tab, the "Active Template" is listed as:

~/Themes/TestTheme/Views/Parts.Common.Body.Summary-Coffeee-Blends.cshtml

This is an alternate of the default template Parts.Common.Body.Summary, based (I presume) on the dynamically generated content type for the terms of the taxonomy. If I view the definition for the "Coffee Blends Term" content type, it shows as its name being "Coffee Blends Term" with its Content Type Id being "Coffee-Blends".

On the "Template" tab of the Shape Tracing module, it shows the content of my custom template (ie. the cshtml file above). However on the "HTML" tab of the Shape Tracing module it shows the html that is output as being the original (truncated) summarised output presumably from the base template. 

This should be a fairly easy problem to reproduce.

  1. Create a new Taxonomy "Test Items"
  2. Edit the dynamically generates content type "Test Items Term" and add the Body part
  3. Add a term to the "Test Items" taxonomy and give it a few paragraphs of lorem ipsum text in the Body field.
  4. View the taxonomy at "~/test-items" and you should see the body of the term being summarised.
  5. Enable shape tracing and reload the page "~/test-terms", select the summarised body content for the term  and generate the alternate cshtml file "Parts.Common.Body.Summary-Test-Items.cshtml"
  6. Edit this alternate and replace contents with anything (static text or just the full body @Model.Html
  7. Reload the page, and the body summary will still output the summarised excerpt. 
Coordinator
Sep 13, 2012 at 8:16 PM

I don't think you should have hyphens in your content type ID.

Sep 14, 2012 at 12:47 AM

Yep that was the problem. The content type is dynamically generated by the Taxonomy module. I checked in the TaxonomyService.cs code in the Taxonomy module and the method GenerateTermTypeName() is replacing whitespace with dashes "-" instead of just removing the whitespace.

So the following...

        public string GenerateTermTypeName(string taxonomyName) {
            var disallowed = new Regex(@"[^\w]+");
            return disallowed.Replace(taxonomyName, "-");
        }

...should probably be...

        public string GenerateTermTypeName(string taxonomyName) {
            var disallowed = new Regex(@"[^\w]+");
            return disallowed.Replace(taxonomyName, string.Empty);
        }

Coordinator
Sep 14, 2012 at 2:26 AM

I agree. Can you please file a bug?

Jan 7, 2013 at 1:36 AM
bertrandleroy wrote:

I don't think you should have hyphens in your content type ID.

Furthermore to this. I noticed the admin UI allows you to create new content types with hyphens in the content type id.

Should the UI be changed to prevent this?

Are underscores allowable in the content type id?