Copied to clipboard

Flag this post as spam?

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


  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 26, 2017 @ 09:31
    Mike Chambers
    1

    Content Template aka Blueprints... extending the functionality

    Been looking to satisfy a clients requirement for default content in new pages.. and contentTemplates (blueprints) seemed to fit..

    However, saving a contentTemplate and then editing it to remove fields that I want the editor to add for the new page doesn't seem posible.

    Eg I create a news template based on an existing news item content node.

    I really then want to edit the contenttempalte to remove the page title and date as these are things that a new news item based on this template should have to be changed. As these are mandatory fields, I can't then save the contenttemplate.

    So what this means is that the editor creates the new node based on the contenttemplate and then simply clicks publish.. with the wrong date for instance . In the usual new node path this would have got "you didnt' fill in a date from the mandatory setting", which the contenttemplate wouldn't.

    Perhaps it's a simple don't validate contenttemplates on saving? Or have a way of marking which fields should be cleared when a node created from the template...

    Any workarounds?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Oct 26, 2017 @ 09:59
    Lee Kelleher
    0

    Hi Mike,

    There's a ticket in the issue tracker for this... Go up-vote it! :-)

    http://issues.umbraco.org/issue/U4-10507

    Cheers,
    - Lee

  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 26, 2017 @ 13:04
    Mike Chambers
    0

    Ah so there is I've upvoted, and I had added another issue earlier.. (will get listed as duplicate soon I don't doubt)

    Will def upvote// only just realised that validation now stops you part completing a content node.. :-( not a breaking change but all my editors now complain ;-) I fill everything in but don't know the internal ref.. so now I have to start all over again.

    blueprints was so much better from a segregation point of view.. searching contentTemplates doesn't find that issue and searching Content Templates just hits on all the standard templates and content issues.

    Just looking at https://www.nuget.org/packages/Our.Umbraco.TemplatableGrid/0.9.0-alpha https://github.com/lars-erik/our.umbraco.templatablegrid/commits/master

    along side https://our.umbraco.org/projects/backoffice-extensions/attackmonkey-grid-locker/

    to see if that will satisfy my client more.. though having no access to nuget install due to firewall restrictions making that hard.. as not published on our :-) so trying to work out how to break apart the nugetpackage and manually add

  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 26, 2017 @ 13:13
    Mike Chambers
    0

    I'd also seen http://issues.umbraco.org/issue/U4-10578

    maybe this could be a token replacement of #default# in textstrings at least to remove those mandatory content things client side prior to first save/publish of the template?

    Thought not sure where in the pipeline these tokens are replaced, so could still fall foul of the validation....

  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 26, 2017 @ 13:38
    Mike Chambers
    0

    Also just noticed [7.7.4]..

    http://localhost:55722/umbraco/#/settings/contentBlueprints/edit/1135

    url is still Blueprints.. and the sourceCode too... ;-) bit of naming confusion there

    deleteBlueprint: function (id) {
          return umbRequestHelper.resourcePromise(
            $http.post(
              umbRequestHelper.getApiUrl(
                "contentApiBaseUrl",
                "DeleteBlueprint",
                [{ id: id }])),
            'Failed to delete blueprint ' + id);
        },
    
  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 26, 2017 @ 14:36
    Mike Chambers
    0

    wrote a bit of a hacky plugin.... esp that timeout! (only works for textstrings but could be extended?)

    $(window).load(
            function () {
                // once the main view is loaded, inject the service
                angular.element('#umbracoMainPageBody').scope().$on('$viewContentLoaded', function () {
                    //only run if in the content section and a blueprint
                    if (location.hash.indexOf('&blueprintId=') > 0) {
                        // need to watch for a broadcast for editcontent controller loaded, rather than a timeout?
                        setTimeout(function () {
                            $('[ng-controller="Umbraco.PropertyEditors.textboxController"]>input').each(function (i, val) {
                                var $input = $(this);
                                // test if we start with $$
                                if (/^\$\$/i.test($input.val())) {
                                    $input.val("");
                                    $input.trigger('input'); // Use for Chrome/Firefox/Edge
                                    $input.trigger('change'); // Use for Chrome/Firefox/Edge + IE11
                                }
                            });
                        }, 1500);                
                    }           
                });
            }
        );
    
  • Mike Chambers 636 posts 1253 karma points c-trib
    Oct 30, 2017 @ 23:56
    Mike Chambers
    0

    Found a better approach.. after seeing http://issues.umbraco.org/issue/U4-2670#comment=67-25903

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Umbraco.Core;
    using Umbraco.Web.Editors;
    
    namespace SYP
    {
        /// <summary>
        /// Summary description for testing
        /// </summary>
        public class EventStuff : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                EditorModelEventManager.SendingContentModel += (sender, e) =>
                {
                    // we are creating from a blueprint so reset the values indicated
                    // NB actual editing of contenttemplates/blueprints doesn't seem to utilise the SendingContentModel so is unaffected
                    if (e.Model.IsBlueprint)
                    {
                        try
                        {
                            var clearFromBlueprintProperty = e.Model.Properties.Where(p => p.Alias == "clearFromBlueprint").FirstOrDefault();
    
                            if (clearFromBlueprintProperty != null)
                            {
                                foreach (var prop in (clearFromBlueprintProperty.Value as string).Split(','))
                                {
                                    var property = e.Model.Properties.Where(p => p.Alias == prop).FirstOrDefault();
                                    if (property != null)
                                    {
                                        property.Value = null;
                                    }
                                }
                            }
                        }
                        catch { };
                    }                
                };
            }
        }
    }
    

    prob also extend to hide property/tab clearFromBlueprint for all but the contenttemplate editing... Could also do with a propertyeditor to multi select the available nodes from that specific doctype, don't suppose you have one tucked away from your uComponents days? nuPickers doesn't seem to have a property picker :-)

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Nov 02, 2017 @ 14:17
    Martin Griffiths
    0

    We need Content templates for Nested Content and Stacked Content!

Please Sign in or register to post replies

Write your reply to:

Draft