0

I've been asked to create a new top level page based on a current design on a site that I'm working on. To do this I've created a new layout with a new control to display the new content I've been asked to create. This is in the layout along with placeholders etc. for the existing design:

<div class="services-left">
  <sc:Sublayout ID="Sublayout7" runat="server" Path="/layouts/company/controls/ServicesContent.ascx" />
</div>

This is in the control:

<h2>
<sc:Text ID="ServicesTitle" runat="server"  field="Service-Title" />
</h2>
<div class="service-header">
<sc:FieldRenderer ID="ServicesCopy" runat="server" field="Service-Copy" />                    
</div>
<div class="service-body">
<sc:FieldRenderer ID="ServicesList" runat="server" field="Service-List" />                    
</div>

I've also created a new template that contains the fields referenced in the above.

I've added the template to the site and set it to use the layout I've created which it does fine and the existing layout displays correctly, the problem I'm having is that the html from the control shows up fine but it won't pickup the fields from the CM and display them.

Is there an extra step I need to do or something I've missed out?

4
  • 2
    Have you published your templates and your items? Feb 27, 2013 at 10:07
  • Ive published everything I've added and still cant see the content.
    – Jonny2Hats
    Feb 27, 2013 at 10:09
  • 2
    Switch over to your web database (at the right bottom of your Sitecore client is a database-switch option) and check if the fields exist and if they are filled. If they don't exists, you didn't publish the Templates and if they exist but aren't filled, you didn't publish your content item. Feb 27, 2013 at 11:41
  • Thanks Martijn, it seems like that was the problem, before i had only published the top level item for that template and not set it to publish subitems. Thanks for your answer, it has helped me a lot!
    – Jonny2Hats
    Feb 27, 2013 at 14:15

1 Answer 1

5

FieldRenderer uses the FieldName property rather than the Field property. The other Sitecore controls (such as Image and Text) do use Field.

Change that and it should start displaying the content from Sitecore.

7
  • Ive just changed these and there is still no content displaying.
    – Jonny2Hats
    Feb 27, 2013 at 10:26
  • Is your website looking at the same files that you just changed? In my case, I have my website running in c:\inetpub\wwwroot\Website, but my code is all in c:\projects\project a\website. On a successful build the changed files are copied across to the actual website using a post-build event. Another option could be that you've got your cache enabled so it's not picking up the changed file. To make sure of this you can clear the cache on yourwebsite/sitecore/admin/cache.aspx
    – Trayek
    Feb 27, 2013 at 10:33
  • My site is pointing to that file yes, i can see if i change the html in that control it changes when i load the site too. For example i just added a class to the first h2 tag and it showed up when i reloaded the page.
    – Jonny2Hats
    Feb 27, 2013 at 10:37
  • 1
    Might be a silly question: Do you have any typo's in the fieldname? (I notice you put hyphens in the fieldname). Otherwise, might be worth debugging the solution, put a breakpoint in your page_load method and find out what Sitecore.Context.Item is.
    – Trayek
    Feb 27, 2013 at 10:58
  • I thought that too so i did a foreach on pageload which wrote all the fields to the page, it seems the fields that im trying to pick up have no name value(although i have named them in the cms), other fields that are showing up correctly have names but the ones im trying to display show a blank value for their name.
    – Jonny2Hats
    Feb 27, 2013 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.