Copied to clipboard

Flag this post as spam?

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


  • Joshua Crittenden 14 posts 124 karma points
    Jul 29, 2022 @ 19:01
    Joshua Crittenden
    0

    How can content templates be applied to block list elements, OR default values set for them?

    How can content templates be applied to block list elements? OR how can default values be given to blocklist items?

    Currently I do not see a way to apply content templates to element types at all.

    Also, the SendingContentNotification way of setting default values does not work for block list items.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Jul 30, 2022 @ 22:51
    Huw Reddick
    0

    I found this very helpful when playing with Blocklist.

    https://umbraco.com/blog/deep-dive-the-block-list-editor/

  • Joshua Crittenden 14 posts 124 karma points
    Aug 08, 2022 @ 13:10
    Joshua Crittenden
    0

    I haven't gotten anything to work for default values or content templates in block elements. Plenty of things work for normal document types, just not element types within a blocklist.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 09, 2022 @ 12:52
    Huw Reddick
    0

    Hi Joshua,

    You need to create contenttemplates for your elements under the folder \Views\partials\blocklist\components

    The templates should have the same name as the elements doctype

    This is what I have, it is a blocklist that displays menus and content blocks in the page footer.

    enter image description here

    Each available block is an based on an Element (so no default template) This is the content of blocklist view folders

    enter image description here

    CompanyInfo is the template for Company Info, it is a very simple template as the element just contains an RTE, the template code is therefore simpl

    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Cms.Core.Models.Blocks.BlockListItem>;
    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
    @{
        var content = Model.Content;
    
    }
    <div class="flex-fill text-center">
    @content.Value("content")
    </div>
    

    The footermenu is a bit more complex as it contains nested block items, but can post it if you need an example

  • Joshua Crittenden 14 posts 124 karma points
    Aug 09, 2022 @ 13:00
    Joshua Crittenden
    0

    Thank you for your input, I have the partials and everything. I understand pulling block element values and the partial views.

    What I can't seem to figure out is setting default values, or applying content templates (https://our.umbraco.com/documentation/Fundamentals/Backoffice/Content-Templates/).

    For instance, I have an Article element type (blocklist), with a dropdown field that is text-size (small, medium, large). I want that field to default to medium. So, when an editor creates a new block element of type Article, then medium is pre-selected.

    I have tried notification handler to no avail. Similar to this, which only seems to work on standard document types, not element/blocklist: https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/73709-default-value-on-property-in-document-type

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Aug 09, 2022 @ 13:25
    Huw Reddick
    100

    Ok sorry, you mean custom back office views, have you read https://our.umbraco.com/documentation/Tutorials/Creating-Custom-Views-for-Blocklist/

    You should be able to set default values using angular in the template I'm guessing

  • ewuski 99 posts 286 karma points
    Mar 04, 2024 @ 20:53
    ewuski
    1

    Hmm, the question was about the content templates and the answer about content custom views. They are two different things.

    My question is how to apply a custom content template that is of an element type. I can create a content template for an element type in the BO:

    Under

    Settings > Content Templates > Create > Create an item under Content Templates

    I am presented with both document types and element types to use and can create a template fo an element type, eg. block.

    But going to Content and creating a new content - I can't see the way to actually use the added element content template when creating a content.

Please Sign in or register to post replies

Write your reply to:

Draft