Alternate Field Template Naming convention

Topics: General
Sep 9, 2011 at 3:58 PM

I'm having trouble constructing the template name for an alternate for a field.  I have a textbox field called "MyId" on a content type called "MyContent."  I need to make an alternate for this field, only when its on this certain content.  I was thinking it'd be something along the lines of:

Content-MyContent.Fields.Common.Text-MyId.cshtml

This isn't working. Can someone point me in the right direction?

Coordinator
Sep 9, 2011 at 8:55 PM

Did you try using shape tracing to figure it out?

Sep 9, 2011 at 8:59 PM

Yes, shape tracing was pretty much not helpful in this scenario.  My experience with shape tracing has been hit or miss in most of my usage with it.  I couldn't get it to highlight just the text field I was looking to alternate the template on, and anything else jsut gave me the generic content shape with the content + url as as an alternate.  Maybe I'm doing something wrong, but I haven't had good luck with finding things with shape tracing.

Coordinator
Sep 9, 2011 at 9:07 PM

Oh, I had misread. Well, anyways, shape tracing worked for me in this case and gave me this:

Fields.Common.Text-MyContent-MyId.cshtml

Sep 12, 2011 at 5:27 PM

That's exactly the name I came up with.  I'll give it another chance when I get back around to that task...

Sep 12, 2011 at 10:58 PM

That seemed to work, but accessing the value of the textbox for that item isn't working the way I've used it in the past...shouldn't it be:

Model.ContentItem.MyContent.MyId.Value

??

 

This is actually a youtube video, and when I mouseover it with shape tracing, it doesn't highlight, and therefore am not able to get access to its model.

Coordinator
Sep 12, 2011 at 11:03 PM

If you can't mouseover, you can use the shape tree on the left pane of Shape Tracing

Sep 13, 2011 at 2:25 PM
Edited Sep 13, 2011 at 2:25 PM

Interesting, that did work.  I guess I always incorrectly assumed that if you can't mouseover, it wouldn't be included in shape tracing, but that tree showed me the values correctly.  The weird thing I'm still seeing (and maybe this is normal) is that even though I'm using an alternate template for my text field as indicated (Fields.Common.Text-MyContent-MyId.cshtml), shape tracing still shows the active tempalate as "Fields.Common.Text." Should I be
seeing the alternate template there instead? I know it's using the alternate because when I make changes to it, it is reflecting the
changes...

Sep 14, 2011 at 3:16 PM

I actually just noticed this recently too. It seems when you override a shape template for a field, shape tracing doesn't recognize it and still reports that the original template is active. It's actually not - Orchard is obviously doing the right thing and using the override but shape tracing doesn't recognize it.

Coordinator
Sep 14, 2011 at 8:58 PM

Canyou please file a bug for that? Thanks!

Sep 14, 2011 at 9:18 PM

Strange ... I went to take a screenshot to attach to a bug, but it seems to be working correctly. I swear I saw this behavior just this week - it was either while I was working on my recording, or on the site I was preparing for my user group presentation. I'll see if I can recreate it again before I file a bug, to make sure I can provide repro steps.