Jump to content

Show field label besides field name in "edit template" view. Possible?


isellsoap
 Share

Recommended Posts

See screenshot for a better understanding of my question:

post-1086-0-87176800-1375453255_thumb.jp

I have lots of generic field names per template (the generic naming is for scalability/simplicity reasons and necessary), so it would be nice to have the field label show up besides the field name for better overview. Is this possible? The status quo is ok-ish, but the field label showing up would be neat, faster and save me some clicks.

  • Like 1
Link to comment
Share on other sites

Go the template "advanced" tab, and add the fields you want to the "List of fields to display in the admin Page List" input

Diogo,

Am not sure that's what he's after? The screenshot is of the Tempate->Basics screen where you can add fields to the template. He wants those rows/list of fields (the asmList), in addition to the field name, to show the field label. What you are suggesting is for the Page Tree, no?

Link to comment
Share on other sites

Currently you can't show field labels rather than names in the template editor. This part is meant to be for the developer, who would typically know fields by their names rather than labels. Like in your template files, you'd refer to fields here by their names. Field labels are more for clients, language translation, etc.



I would suggest using more descriptive names than float_field_1, float_field_2, etc., because there's no way to tell what that is, outside of the label. It could make the code in your site's template files difficult to maintain and navigate. 

Link to comment
Share on other sites

Thanks for the comments.

@ryan: like I wrote in the first post, the generic names are necessary because of scalability reasons in the long run. The fields represent single entries of companies’ quarterly results. Because of the heterogenity of those results (every company has slightly different naming conventions for their financial stuff), it wouldn’t be very wise to create 30 to 50 fields per company (that would result in 30,000 to 50,000 fields for 1,000 companies). Instead, I have 50 generic field names for 1,000 companies.

I think also that it is definitely a bit difficult to navigate through template files (in my case the fields are used in a module) and check, which field represents what for a single company, but I think it’s far better than having thousands and thousand of fields in total.

Link to comment
Share on other sites

I think also that it is definitely a bit difficult to navigate through template files (in my case the fields are used in a module) and check, which field represents what for a single company, but I think it’s far better than having thousands and thousand of fields in total.

I can think of different ways to deal with this one. 

  1. Printout: As someone suggested in the forums (Maybe Renobird?), they print out a list of all the fields on their site and what the fields are for.
  2. Admin page: Maybe create a hidden page, under Admin, with a list of all the fields and what they represent for each company?
  3. Custom Admin page: Create a custom admin page using Diogo's Admin Custom Page module that renders only for superuser showing you the list of fields and what they represent for each company. Maybe this is best because you can view it as read only and can get as creative as you want with the output

Just thinking out loud here...

  • Like 3
Link to comment
Share on other sites

@ryan: like I wrote in the first post, the generic names are necessary because of scalability reasons in the long run. The fields represent single entries of companies’ quarterly results. Because of the heterogenity of those results (every company has slightly different naming conventions for their financial stuff), it wouldn’t be very wise to create 30 to 50 fields per company (that would result in 30,000 to 50,000 fields for 1,000 companies). Instead, I have 50 generic field names for 1,000 companies.

Sounds like you have pretty unique needs here, and I understand now – your approach does make sense given the context. I think Kongondo's ideas are good here, and I will keep thinking about how we might support separate labels in the asmSelect list there for the future. 

  • Like 1
Link to comment
Share on other sites

  • 3 years later...

Similar (related) question. I have templates with up to 50 fields. I don't work in the Admin much but do use it to lookup values on pages and with my poor memory, and even with pretty good naming convention for my fields (some are similar) I often lose track of field names. Is there any way (short of manually appending the field name to the label) to show both label and field name above the field input. Essentially, is there somewhere an option to automatically append the field name to the field label. Please see screenshot for basic idea:

Thx

2017-04-25 14_29_03-Edit Page.png

Link to comment
Share on other sites

You can do this with a few lines of JS

(function(){
    let inputs = document.querySelectorAll('.InputfieldWrapper .Inputfield');

    [].forEach.call(inputs, item => {

        let input = item.querySelector('[name]');
        if(!input) return;

        let label = item.querySelector('label');
        if(!label) return;

        let inputName = label.htmlFor.replace(/(\w+)_(\w+)/, '$2');


        let span = document.createElement('span');
        span.style.display = 'inline-block';
        span.style.color = 'tomato';
        span.style.border = '2px solid';
        span.padding = '0.25em 0.25em';
        span.margin = '0 0 0 0.25em'

        span.innerHTML = inputName;
        label.appendChild(span);

    });
})();

Run this in Developer Console on your browser and you'll get this

chrome_2017-04-25_08-22-24.png.b4462b95f20a5eafcc3be826ce2eff8d.png

To automate this, you can put this script in a JS file in /site/templates/admin/labels.js, and enqueue it inside your /site/ready.php

// /site/ready.php

if ($page->template->name === 'admin') {
    $config->scripts->add($config->urls->templates . 'admin/label.js');
}

 

  • Like 5
Link to comment
Share on other sites

  • 2 weeks later...

Hey @abdus, Thank you! I was not aware you could do anything like this! Love it.
BTW the ugly styling in my screenshot was just the default from the snipping app, I never meant you to copy it so accurately! Bonus points for that.

@tpr thanks for the AdminOnSteriods suggestion, it looks interesting, will check it out. Cool name too.

Link to comment
Share on other sites

  • 1 year later...
On 5/5/2017 at 11:47 AM, Robin S said:

One more option: when debug mode is true you can hover the inputfield open/close toggle to see the field name.

2017-05-05_164623.png.97e9bdc71ccd2c7ad2e64c404bce1b7f.png

Is there anyway to always enable this whether debug mode is on or off ? this is really usefull.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...