queue  8
support
Results 1 to 3 of 3

Thread: Adding a title to the top of newly created blocks

  1. #1
    Junior Member
    Join Date
    Feb 2017
    Posts
    2

    Adding a title to the top of newly created blocks

    Hi there,

    Thanks for the Momentum theme. I am enjoying making use of it and it is simple to use to match our customer's requirements.

    There is a feature that would be useful, that sort of already exists, and I would like to know how to use it. (It might be a bug). I'll explain.

    If, in the page editor, I click on, 'Services,' a new section is automatically created, with an editable content block already there, with the title of Branding. If I carry out an inspect element on the head of this content block, amongst many other things, I see this:

    Code:
    <h3><span class="title">Branding</span><span class="type">Service</span><i class="collapse"></i></h3>
    and, the
    Code:
    <span class="title">Branding</span>
    alters depending on what I enter into the, 'Title,' field. This is an incredibly useful feature, as, when the editable content blocks are collapsed, it is easy to tell which is which and makes moving them around a snap.

    Inspecting the header of the, 'Services,' section, I see this:

    Code:
    <h3><span class="title"></span><span class="type">Services</span><i class="collapse"></i></h3>
    The, 'title,' span is present, but it is empty. And, it has a
    Code:
    display: none;
    set on it.

    It would be very useful if the, 'title,' span were made use of in the same way with sections as it already is with editable content blocks, so I, and our customers, would easily be able to keep track of which sections they would need to edit.

    Please could you let me know which, if any, php files I would need to edit to make this happen and what the edit should be, or, could this feature be included in a future update of the theme?

    With kind regards,

    Mark

  2. #2
    Lead Support Ante's Avatar
    Join Date
    Oct 2012
    Posts
    16,930
    Hello Mark,

    thank you for going in details about your request, it makes perfect sense.

    Please try this, go to theme folder/js/admin/layout and open jquery.theme.layout.module.container.js

    Replace the contents of the file with this:
    Code:
    (function ($) {
      "use strict";
      /*jslint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false */
      /*jshint undef: false, browser: true, devel: false, eqeqeq: false, bitwise: false, white: false, plusplus: false, regexp: false, nomen: false, validthis: true */
      /*global jQuery,setTimeout,clearTimeout,projekktor,location,setInterval,YT,clearInterval,pixelentity,prettyPrint */
    
      function addID(v) {
        return ".group_"+v;
      }
    
      function module() {}
    
      var standard = $.pixelentity.peFieldLayout.modules.Standard.prototype;
    
      $.pixelentity.peFieldLayout.addModule("Container",module,{
        config: function() {
          this.container = true;
          this.allowed = this.conf.allowed ? [this.conf.allowed] : [];
          this.sortable = this.conf.allowed || "block";
        },
        template: function(target) {
          this.titleField = target.find(".config input[type=text],.config select").eq(0);
          this.target = target;
          this.items = target.find("ul.pe_block_container:first");
          return target;
        },
        init: function(data,isNew) {
          this.titleField.on("change",$.proxy(this.title,this)).trigger("change");
          if (isNew && this.conf.create) {
            this.first = this.master.addBlock(this.conf.create,this.items);
          }
        },
        add: function() {
          if (this.conf.force) {
            return this.master.addBlock(this.conf.force,this.items,"append",true);
          }
          return false;
        },
        title: standard.title,
        filter: function() {
          return this.allowed.length > 0 ? this.allowed.map(addID).join(",") : false;
        }
      });
    
    }(window.jqpe35 || jQuery));
    Save, and your sections should now have titles as well.

  3. #3
    Junior Member
    Join Date
    Feb 2017
    Posts
    2
    Hi Ante,

    Thanks for getting back to me, and apologies for taking a while to get back to you - I was away on holiday when you replied.

    I've just modified the file you suggested, using exactly the code you supplied, and it has added the titles exactly as requested. In fact, it has done more than that ... If there is a newly added block that is Columns, it displays how the columns are split up. Very useful.

    If anybody else comes across this forum post, looking to do exactly the same thing, then I should add a wee bit to Ante's response by saying that the full file path is: [theme folder]/framework/js/admin/layout/jquery.theme.layout.module.container.js ;-)

    Thanks again,

    Mark