Copied to clipboard

Flag this post as spam?

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


  • Mike Manusama 45 posts 195 karma points
    Sep 25, 2023 @ 13:55
    Mike Manusama
    0

    Adding CSS Class to a layout block

    I'm sure this is easy, but I am having a rough time transitioning from the Grid Layout to block grid. With the grid layout, I was able to easily apply a class to a row or column. With this new set up I am trying to take an approach to allow the user to add some css classes to the sections themselves for added styling. I keep getting an error back around the value of the textbox in the settings portion.

    I created the data type here in the settings section of my layout I created the data type here in the settings section of my layout

    Here is the Partial View for this Here is the Partial View for this

    Here is the error that I am getting Here is the error that I am getting

    I have tried grabbing the Value with a few different methods. All of them seem to generate an error.

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Sep 26, 2023 @ 08:08
    Marc Goodson
    0

    Hi Mike

    Have you regenerated Modelsbuilder models and rebuilt the solution since you added the new CSSClasses property?

    because on the line above you are reading the Contrast value and that doesn't appear to error?

    And the error is saying that SectionSettingsBlock doesn't appear to know what CSSClasses is...

    so feels like the dynamically generated class for SectionSettingsBlock is missing the new property?

    If you look at your Modelsbuilder settings in AppSettings, if you are running in 'SourceCodeAuto' mode then it should show the path to where the models are being generated, and you could look to see if the SectionSettingsBlock has the property or not.

    additionally you could check by seeing if

    var cssClasses = Model.Settings.Value<string>("cSSClasses");
    

    finds the value, as this 'bypasses' the model property to look on the underlying IPublishedElement, if this is populated then it would show it's the generation of your SectionSettingsBlock model after adding the new property that is awry.

    regards

    Marc

  • Mike Manusama 45 posts 195 karma points
    Sep 27, 2023 @ 19:46
    Mike Manusama
    0

    Thank you!

    I think it didn't like the Css classes name. I changed it to "classes" and that seemed to do the trick. Either that or the models rebuilt, I am not sure. Either way - it seemed to be addressed

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Sep 28, 2023 @ 04:51
    Chriztian Steinmeier
    0

    If I remember correctly, the generated property would be named CssClasses (or maybe even Cssclasses) by ModelsBuilder, if typed in as "CSS Classes".

    I have developed a pattern of naming my properties like this when creating them (i.e. typing in "Css Classes") and then renaming the label after saving the property to get the proper CSS Classes displaying.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft