How does this work?

Feb 9, 2011 at 6:23 AM

I must be missing something here. I've created some taxonomies and terms. Now what do I do with them? How do I associate terms/taxonomy with say a page or blog post? Or is it meant for other types of content? If so, how do I create those content items with a particular taxonomy? I've tried adding a taxonomy field to a page, but it just displays the name of the field with nothing else when I go to edit a page. I'm sure its very simple, but the concept escapes me.

Feb 9, 2011 at 8:36 PM

Adding a Taxonomy to a Content Type

  • In the admin panel, click on Content Types
  • Click on Edit fot the content type you want to modify
  • In front of Fields, click Add
  • Give it a name, and select TaxonomyField
  • Click Save
  • Expand the new Field section
  • Select the desired taxonomy name
  • Click Save

Can you see this specific section ? Because here you can define which taxonomy to use on a type, and how they should be displayed.

Feb 9, 2011 at 10:08 PM

I knew I was missing something so simple. I was not expanding the new field settings after adding the taxonomy field. Now it all makes sense.

Feb 9, 2011 at 10:25 PM

Ok, so now that I have some terms and I've added a taxonomy field to Page and selected the taxonomy and I can select the terms now when I create a new page. Maybe I've screwed up my installation so bad now that I need to reinstall, but I'm still getting an error when I try to goto /{taxonomy}/{term} even though I have a page with the term selected. I'm thinking maybe the content type needs to be containable so that page can show them in a list. I guess I'll try that next. The error I get is below, when I step into the controller I can see that its not finding any content items associated with the term so it returns a null model or something like that which causes this error, maybe a more graceful failure with some help on how to fix the problem would be appropriate. When I get this figured out I wouldn't mind contributing some code for that.


Attempt by method 'DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, Contrib.Taxonomies.Controllers.HomeController, System.Object)' to access method 'System.Web.Mvc.Controller.View(System.Object)' failed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.MethodAccessException: Attempt by method 'DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, Contrib.Taxonomies.Controllers.HomeController, System.Object)' to access method 'System.Web.Mvc.Controller.View(System.Object)' failed.


Feb 9, 2011 at 10:43 PM
Edited Feb 10, 2011 at 5:09 AM

I got this working but not on my local machine. It works in azure. I found another discussion on the orchard group about this error and it seems casting the model to object before returning from the controller will fix it.  I haven't tried yet, but at least I got it working in the cloud.

Feb 15, 2011 at 5:02 PM

The casting issue is relative to medium trust nad C# dynamics. Thus it is solved on Azure as you run in Full Trust by default. If you switch trust="medium" by "full in your local web.config it will work too.

Yet, it's a bug, and I shall correct it.

Feb 15, 2011 at 8:40 PM

I saw a comment that makes me think they had a similar issue in Orchard.Core\Containers\Controllers\ItemController.cs where they cast the ViewModel to an object to avoid some issue, could this be all you need to solve this too? I'm really just shooting in the dark here.

Feb 15, 2011 at 11:28 PM

Yes this is it, I have pushed a fix this morning, just after my message.