This project is read-only.

Taxonomy terms don't display automatically?

Topics: Customizing Orchard
Aug 29, 2012 at 4:38 PM

I want to create a new content item on the front-end. The content type contains a taxonomy field with a couple of terms. It seems I use the standard way of doing it

public ActionResult Create(string id)
     var contentItem = _contentManager.New(id);
     if (!Services.Authorizer.Authorize(Orchard.Core.Contents.Permissions.EditContent, contentItem, T("Cannot create content")))
         return new HttpUnauthorizedResult();
     dynamic model = _contentManager.BuildEditor(contentItem);
     // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation.
     return View((object)model);
and @Display(Model) in the view.

The problem is that taxonomy field is shown as field name only without a glyph and all terms are hidden. What is responsible for that behaviour?

Any hints please?

Aug 29, 2012 at 8:28 PM

Can you set a breakpoint in the TaxonomyFieldDriver and ensure it's being executed without exceptions?  Usually if a part doesn't display at all, there was an error thrown somewhere.  

Aug 29, 2012 at 10:00 PM

Thanks for your response.

I don't say it doesn't display at all. It is displayed but as a field name only without a glyph. The terms ARE in the html but they are invisible (display: none) and  I can't expand the field without a glyph. I say again: it is on the front-end. On admin side the same content type is displayed fine.

Aug 29, 2012 at 10:59 PM

Did you check if the resources that are required by the TaxonomyField are correctly included in the front end? Any errors in firebug regarding the loading of resources?

Aug 29, 2012 at 11:51 PM
Edited Aug 30, 2012 at 12:09 AM

No errors in firebug... But I have found that javascript function expanding the field (expandocontrol) is in Admin theme in admin.js file. May be it is kind of security problem and that file is not accessible from the front-end? How to show terms then?

Aug 30, 2012 at 2:07 PM

What happens if you include that admin.js file directly using the full path to it?

Aug 30, 2012 at 6:25 PM
Edited Aug 30, 2012 at 6:53 PM

I included it through Script.Require, it is on the page now and nothing happens. No glyph and no possibility to show the terms


    <span class="expando-glyph-container closed">
    <span class="expando-glyph"> </span>
Test Address
<div class="expando" style="display: none;">
<input id="ContactPart_Testik_Terms_0__IsChecked" type="radio" name="ContactPart.Testik.SingleTermId" value="74">
<input id="ContactPart_Testik_Terms_0__Id" type="hidden" value="74" name="ContactPart.Testik.Terms[0].Id">
<label class="forcheckbox" for="ContactPart_Testik_Terms_0__IsChecked">AddressType 1</label>
<input id="ContactPart_Testik_Terms_1__IsChecked" type="radio" name="ContactPart.Testik.SingleTermId" value="75">
<input id="ContactPart_Testik_Terms_1__Id" type="hidden" value="75" name="ContactPart.Testik.Terms[1].Id">
<label class="forcheckbox" for="ContactPart_Testik_Terms_1__IsChecked">AddressType 2</label>


Aug 30, 2012 at 9:03 PM

Perhaps it requires ShapesBase and other resources, like specific styles?

Aug 31, 2012 at 5:10 PM

But firebug should notice any resource lack, shouldn't it? Not sure about ShapeBase though...

Sep 6, 2012 at 2:40 PM
Edited Sep 6, 2012 at 2:45 PM

Hello, I have had the same problem. I think it's a bug in Orchard, the Glyph was in the html, but it just wasn't visible. I managed to fix it by adding the following to the site.css in the theme called "TheAdmin":

.primary .expando-glyph
    display: inline-block;
    position: static;

The problem is that there is a negative left-margin on the glyph and that puts it outside it's container. That is mostly not a problem, but in this case I think it gets hidden under a parent container. I have tried fixing it by setting z-indexes, but that didn't work for me.

Also, I only had that problem (if I remember correctly) when the taxonomies field was on a content type, not when it was on a content part (but it could also have been the other way around).

Sep 9, 2012 at 7:58 PM

But the glyph is visible if you show it on Admin GUI so it seems it is somewhere in the code where the visibility is controlled...

Sep 29, 2012 at 9:06 AM
Edited Sep 29, 2012 at 9:06 AM

The expando-glyph css rules are defined in site.css in the TheAdmin theme. So it makes sense that the expando control is not visible on the front end. If you copy the required CSS to your own theme, it should work.