Copied to clipboard

Flag this post as spam?

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


  • James Dodwell 21 posts 73 karma points
    Apr 08, 2015 @ 18:01
    James Dodwell
    4

    Changing 'item 1' to 'something 1'

    Is it possible to change the 'Name Template' so it displays a word of my choosing followed by the index number.  I've tried a few things like:

    Content Block {{id}}

    Content Block {{index}}

    Content Block {{$index}} 

    Thanks for any help you can give and for creating a great package!!

  • James Dodwell 21 posts 73 karma points
    Apr 23, 2015 @ 13:16
    James Dodwell
    0

    Can anyone help provide an answer to my question?  Many thanks,  James

  • suzyb 474 posts 932 karma points
    Apr 23, 2015 @ 20:34
    suzyb
    101

    I came here looking for an answer to the same question.  

    SInce there doesn't seem to be one though, I had a look at the controller getName function and it doesn't (at least to my angular noob eyes) look like there is a way to do this with a template.  So what I did was simply change the string literal "Item" that is used in the default name to "Block".

    File is located App_Plugins\NestedContent\Js\nestedcontent.controllers.js and the string to change is on line 81.

  • James Dodwell 21 posts 73 karma points
    Apr 27, 2015 @ 15:12
    James Dodwell
    1

    Hi Suzyb,

    That has given me a solution to my problem.  Thank you very much!

    James

  • Emma Garland 41 posts 123 karma points MVP 7x c-trib
    Mar 21, 2017 @ 16:41
    Emma Garland
    0

    Thanks for the headsup Suzyb - have since checked and it is now Line 196 of App_Plugins\NestedContent\Js\nestedcontent.controllers.js :

    var name = "Item " + (idx + 1);
    

    I extended this slightly - I needed to be able to view and edit the titles of each nested content item. This may not be exactly right but what I did was:

    • create a new docType called "NC - Shared - Item Title" with a single property called "Title"
    • added it via composition to each of my Nested Content items (e.g. "NC - Info Text Slice")
    • changed the Nested Content nestedcontent.controllers.js code as follows:

      $scope.getName = function (idx) {
      
      
      if ($scope.model.value[idx]) {
          if ($scope.model.value[idx].title) 
          {
              name = $scope.model.value[idx].title;
          } 
      else 
          {
              name = "Item " + (idx + 1);
          }
      

    This now takes my newly added "title" property instead of "Item " + x, but if title is missing it should use Item X instead. Changing the title immediately changes it in the back-end:

    Nested content

    Of course test this and customise this to your own specific needs/feedback any bugs - but hopefully it gives a further option in terms of adding a title and helping to work through long lists of nested content items (have seen this done on a list of locations before).

    Emma

  • Ashkan Sirous 38 posts 232 karma points
    Aug 25, 2017 @ 10:10
    Ashkan Sirous
    9

    Strange, but I was able to do it very easily.

    definition view

  • blackhawk 313 posts 1368 karma points
    Dec 15, 2017 @ 17:24
    blackhawk
    2

    Thanks Ashkan! I was wondering what Name Template was meant for. Now understood.

  • Emma Garland 41 posts 123 karma points MVP 7x c-trib
    Jun 27, 2018 @ 12:26
    Emma Garland
    1

    Hi,

    Just found my own post after coming across the issue again, and you're totally right Ashkan. I clicked to expand the help text next to the "Add" button and it does tell you how to do this:

    Nested Content Help

    Can confirm, works without needing to edit the code :D

    Emma

  • Raluca Dumitru 33 posts 174 karma points
    Nov 23, 2018 @ 16:50
    Raluca Dumitru
    0

    Does anyone know how to style these separately?

  • Emma Garland 41 posts 123 karma points MVP 7x c-trib
    Apr 04, 2019 @ 15:59
    Emma Garland
    2

    Just to update this based on the Nested Content in Core (and have tested on Umbraco Version 8)

    If my property name is "propertyName" and I want the Name and number to be included in the Nested Content view, the syntax in the template editor is:

    {{propertyName | ncNodeName}} {{$index}}
    

    This will show:

    enter image description here

    This is as per Dave Woestenborghs reply https://our.umbraco.com/packages/backoffice-extensions/nested-content/nested-content-feedback/91350-nested-content-template-field and the documentaiton https://our.umbraco.com/documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content/#configuring-nested-content

  • Proxicode 128 posts 324 karma points
    Mar 14, 2022 @ 16:57
    Proxicode
    0

    This question is pretty old and has been pretty well answered, but just wanted to add that you can also combine plain text with calculated values like

    Column {{index}}
    

    Which of course would generate "Column 1" etcenter image description here

Please Sign in or register to post replies

Write your reply to:

Draft