Model.ContentType VAR Values Not Populating?

Topics: Troubleshooting
Jun 9, 2011 at 9:09 PM

My role on this project is essentially UI layer, limited MVC3 Experience...so far.

  1. I have created a simple contenttype called "WSCapability",
    1. Fields for ContentType
      1. CapabilityTitle
      2. CapabilitySubhead
      3. Body
  2. Created a contenttype view page for HTML structure and some Jquery (is inlcuded in rendered DOM) at "views/items/Content-WSCapability.cshtml".
  3. Then I added the contentype to a page.

Results:

The correct view is being injected into the page as expected but none of the values appear to be populating? Any ideas, ran thru debugger but really doesnt help me if I have limited MVC3 at this point. Any ideas of why my vars may not be populating?

NOTE: var contentTypeClassName Value = "w-s-capability" (is this significant to my issue?)

Thanks in advance.

(ContentType View Code Below)

@using Orchard.Utility.Extensions;
@{
    Layout.Title = Model.Title;
    var contentTypeClassName = ((string)Model.ContentItem.ContentType).HtmlClassify();
  }
 
<div class="SkillsSmartsBox" style="border-top:1px solid #666666; width:300px;">
    <div class="boxLeft">
        <p><span class="SSViewD">&nbsp;</span></p>
    </div>
    <div class="boxRight">
        <h2 class="para title1"><span class="panelTitleD">@Model.CapabilityTitle</span></h2>
        <p class="skilldescrip">@Model.CapabilitySubhead </p>

        <a href="#" class="collapsePanel">-</a> 

        @Model.Body
     
    </div>
    <div class="clear"></div>   
</div>

Coordinator
Jun 9, 2011 at 10:34 PM

I think you need to go through the content item and the part. Use Shape Tracing to determine how to get to your properties. I'd guess something like Model.ContentItem.WSCapability.CapabilityTitle.

Jun 10, 2011 at 4:18 PM

Well I installed Shape Tracing Module, but it certainly is not behaving as I would have hoped. Upon launch I had many .js errors, so my assumption was that some of my jquery includes @document level were stepping on the shapetracing mod and its jquery, so commented out my references in document, but still having alternative .js issues with this module. I do get some functionality now, but its still almost unusable for all practical intents. I certainly have no editing capabilities as documentation states, but do see some limited model information. Using IE8/FF4. Any ideas or posts that may be helpful in resolving this issue that you are aware of? Done some searching but nothing seems to be relevant so far. I can certainly see how this module might be helpful (if i could get it to work) :). Take any links you may be able to provide.

Thanks.

Jun 10, 2011 at 4:57 PM

When you include jQuery, do you do it with @Script.Require("jQuery") - because that's how you should do it to avoid conflicts.

Jun 10, 2011 at 4:59 PM

Document.cshtml 

I have been commenting these out, is this wrong?

/* Global includes for the theme
    ***************************************************************/
    Script.Include("jquery-1.4.4.min.js").AtHead();
    Script.Include("jquery.collapser.min.js").AtHead();
   Script.Include("jquery.juitter.js").AtHead();
    Script.Include("system.js").AtHead();
    Script.Include("Capabilities.js").AtHead();

Jun 10, 2011 at 5:04 PM

so to your point, I should change my include references to follow the syntax above on my document.cshtml file?

Jun 10, 2011 at 5:20 PM

I'm saying the way you're including jQuery is wrong. Orchard comes with its own version of jQuery, which some of the core modules rely on. There's a system of named resources, so instead of including your own copies of the files you use a centralised resource which everything has access to. Meaning that your website has to access less files, namespace conflicts are avoided, and you always get the latest version when Orchard is updated. The correct syntax is:

@Script.Require("jQuery").AtHead();

You can look at ResourceManifest.cs in the Orchard.jQuery module to see all the other scripts that are already available. You should also use the resource manifest name if one is available; if not, you can implement your own resource manifest, and that script will then also be available for other modules or themes that use yours.

Jun 10, 2011 at 5:27 PM

roger that, think i know what we're talking about now, inherited some of this framework, just the UI guy...and sometimes developer guy (drinking from the firehose). Thanks.