Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bikeman 21 posts 103 karma points
    Oct 24, 2019 @ 14:30
    bikeman
    0

    Render grid in template not working

    Hi

    I want my content grids to render Foundation rather than Bootstrap markup.

    I've included a Foundation5 grid renderer in /views/partials/grid/

    My understanding is that this will use Foundation CSS markup when editor's add content grids. Is this correct?

    I've added @Html.GetGridHtml(Model,"propertyAlias","Foundation5") to my master template but it's not valid and I get:

    Exception Details: System.NullReferenceException: No property type found with alias propertyAlias

    What is the propertyAlias for the content grid? I've tried bodyText, content, contentGrid etc

  • Paul Griffiths 370 posts 1021 karma points
    Oct 24, 2019 @ 14:41
    Paul Griffiths
    0

    Hi Bikeman,

    As per the official documentation (https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/grid-layout/render-grid-in-template) the following should work

    @Html.GetGridHtml(Model, "propertyAlias", "bootstrap2")

    The property alias is defined by you when you add the grid to your document type. In my example here my alias is 'gridContent'

    enter image description here

    So my call in my view would be

    @Html.GetGridHtml(Model, "gridContent", "bootstrap2")
    

    Hope that helps.

    Thanks Paul

  • bikeman 21 posts 103 karma points
    Oct 24, 2019 @ 14:50
    bikeman
    0

    Hi

    Thanks for the reply. I have a new install with the demo site and I can see that the item you refer to in my case is 'bodyText' but it's not working.

    I've included @Html.GetGridHtml(Model,"bodyText","Foundation5") in my master

    enter image description here

    enter image description here

  • Paul Griffiths 370 posts 1021 karma points
    Oct 24, 2019 @ 14:56
    Paul Griffiths
    0

    Hi Bikeman,

    Are you using Models builder, if yes, which mode are you using and have you generated your models ?

    Are you able to share your code? i might help to understand the issue more.

    You might need to pass in Model.Content as thats the IPublishedContent

    @Html.GetGridHtml(Model.Content,"bodyText","Foundation5")
    

    Have a read through this post https://our.umbraco.com/forum/umbraco-8/95845-render-grid-in-umbraco-8. It might be similar

    thanks
    Paul

  • bikeman 21 posts 103 karma points
    Oct 24, 2019 @ 15:12
    bikeman
    0

    Sorry I don't understand what you're asking.

    All I've done is install umbraco with the demo site included it has a blog page and I've just tried to change the grid renderer from the default to Foundation by add the renderer from here

    https://our.umbraco.com/packages/developer-tools/umbraco-grid-renderers/

    and following the instructions from here

    https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/grid-layout/render-grid-in-template

    I can't see anything in that post that helps. Here's my template

    enter image description here

  • Paul Griffiths 370 posts 1021 karma points
    Oct 24, 2019 @ 15:28
    Paul Griffiths
    0

    Hi,

    Sorry, I'm just travelling on the train. Did you try passing in Model.Content instead of just model?

    Your error is suggesting that bodyText doesn't exist on the Model you are passing in

    Paul

  • bikeman 21 posts 103 karma points
    Oct 24, 2019 @ 15:37
    bikeman
    0

    I tried that (though the post you gave me does say in umbraco 8 the RenderModel has been simplified from Model.content to Model).

    It results in Compiler Error Message: CS1061: 'IPublishedContent' does not contain a definition for 'content'

  • Paul Griffiths 370 posts 1021 karma points
    Oct 24, 2019 @ 15:53
    Paul Griffiths
    0

    Hi,

    Sorry just looked at your screen shots again, your bodyText is defined on the blog Post documentType and it looks like you are trying to render it out on the master template.

    Try moving your original code to the blogpost template. (using Model)

    Failing that i will load up a new instance of V8 and install the starter kit to have a look for you.

    Apologies, im trying to help from my phone on the train.

    thanks Paul

  • bikeman 21 posts 103 karma points
    Oct 24, 2019 @ 16:06
    bikeman
    1

    Partial progress.

    Moved @Html.GetGridHtml(Model,"bodyText","Foundation5") from Master into the Blogpost template.

    Got rid of the error BUT now the blogpost renders twice on the page: firstly with Foundation markup, then again with Bootstrap markup.

    I'm also why I have to include this on the blogpost template since blogpost is rendered within the master layout? This makes a bit of a nonsense of using master pages.

  • Rob Shaw 37 posts 170 karma points c-trib
    Oct 28, 2019 @ 18:09
    Rob Shaw
    0

    Hi bikeman,

    Something to try; are you using @RenderBody() in the master template?

    <body>
    
    @RenderBody()
    
    </body>
    

    That will output the blog post content with the master page wrapper, also make sure that there is no reference to the @Html.GetGridHtml(Model,"bodyText","Foundation5") in the master template.

    As for the doubling of content: make sure your renderer does not have any of the bootstrap renderer markup in.

    If you could share your master and blog template I might be able to help further!

    Take care, Rob

Please Sign in or register to post replies

Write your reply to:

Draft