Jump to content
Robin S

Template Field Widths

Recommended Posts

Another little admin helper module...

Template Field Widths

Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

screencast

Why?

When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.

Installation

Install the Template Field Widths module.

Config options

  • You can set the default presentation of the "Field widths" field to collapsed or open.
  • You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover.
  • You can choose to show the original field width next to the template context field width.

 

https://github.com/Toutouwai/TemplateFieldWidths
https://modules.processwire.com/modules/template-field-widths/

  • Like 23
  • Thanks 2

Share this post


Link to post
Share on other sites

Cool! Add an arrows-h icon to the InputfieldMarkup? Make the widths with the slider instead of text input? Dynamically show the width of fields as they change?

  • Like 2

Share this post


Link to post
Share on other sites

@matjazp, thanks for the suggestions.

42 minutes ago, matjazp said:

Add an arrows-h icon to the InputfieldMarkup?

Yes, done in v0.1.2

42 minutes ago, matjazp said:

Make the widths with the slider instead of text input?

Sorry, no, if I'm wanting numbers to sum to exactly 100 then I much prefer a number input than a slider. Just tab from field to field and it's very quick.

42 minutes ago, matjazp said:

Dynamically show the width of fields as they change?

Great idea, done in v0.1.2

  • Like 2

Share this post


Link to post
Share on other sites
6 hours ago, Robin S said:

Another little admin helper module...

...with a not so little impact when building complex sites. I already know I'm going to use this a lot 🙂 Thank you!

  • Like 3

Share this post


Link to post
Share on other sites

Very nice 😍

I used to have a separate template and output everything in a HTML table. Just to get an overview of it. But this is much better!

How about putting the original with in a light gray somewhere? I am always interesetd wether I changed the value in template context or not.

  • Like 2

Share this post


Link to post
Share on other sites

Seriously brilliant @Robin S - this is going to be an absolutely huge timesaver!

I think this deserves a screencast in the first post showing the layout change dynamically as percentages are adjusted - so cool!

  • Like 2

Share this post


Link to post
Share on other sites

What do you think about having fieldsetTabs actually separated out into tabs in the editing interface - I think this would be a really helpful addition.

  • Like 1

Share this post


Link to post
Share on other sites
On 11/22/2018 at 9:11 PM, Klenkes said:

How about putting the original with in a light gray somewhere? I am always interesetd wether I changed the value in template context or not.

Personally I would find that more distracting than useful, but will look at adding it as a configurable option.

On 11/23/2018 at 7:48 AM, adrian said:

What do you think about having fieldsetTabs actually separated out into tabs in the editing interface - I think this would be a really helpful addition.

I can see why this would be good, but I wouldn't want to lose the ability to use the tab key to move through all fields in the template. Will do some experimenting and see if it's possible to keep the tab key navigation in a tabbed interface - I have a feeling that hidden inputs may not be focusable with tab.

Share this post


Link to post
Share on other sites
2 minutes ago, Robin S said:

I have a feeling that hidden inputs may not be focusable with tab.

Tabbing works find in the PW admin when editing a page - you can use the tab key to move between fields in any of the WireTabs - Content, Custom tabs, Settings, etc. Maybe I am not understanding the issue you are referring though ?

Share this post


Link to post
Share on other sites
1 minute ago, adrian said:

Tabbing works find in the PW admin when editing a page - you can use the tab key to move between fields in any of the WireTabs - Content, Custom tabs, Settings, etc. Maybe I am not understanding the issue you are referring though ?

My objective is to avoid needing to mouse to and click anything in the "Field widths" field. Right now I can use the tab key to move through all the fields, but if some fields are inside a hidden tab content div then I suspect it may be quite difficult to keep this functionality. If it were just a matter of showing the tab content with the focused field that would be fairly simple, but I suspect the browser will refuse to focus an input inside a hidden div (I haven't checked yet).

In the PageEdit/WireTab example, PW will not move focus from the last field in Tab A to the first field of Tab B using the tab key.

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Robin S said:

In the PageEdit/WireTab example, PW will not move focus from the last field in Tab A to the first field of Tab B using the tab key.

Of course - sorry, I didn't realize that was a goal. I guess I thought it would be ok to use the mouse to activate the other tab.

Perhaps an alternative would be to just separate out other tabs below the main Content tab so they are separate. I just think this would help with visualizing the layout better, because at the moment it looks like the fields in other tabs are all part of the one form, which of course they are not, visually speaking.

Anyway, not a big deal 🙂

Share this post


Link to post
Share on other sites

v0.1.3 adds a tabbed interface for fieldset tabs, and there is a new config option to show the original field width alongside the template context field width.

  • Like 1

Share this post


Link to post
Share on other sites
7 hours ago, Robin S said:

v0.1.3 adds a tabbed interface for fieldset tabs, and there is a new config option to show the original field width alongside the template context field width.

Thanks @Robin S - I see that adding the tabbed interface was a significant amount of work - I think it's awesome though so thank you 🙂

One small thing - it needs a fallback to tab_name if there is no label set. This should be an unlikely scenario, but without it, you can't get to the other tabs.

            $markup .= "<li class='tfw-tab{$active}' data-tab='tfw-{$tab_name}'>" . ($tab_data['label'] ?: $tab_name) . "</li>";

 

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, adrian said:

One small thing - it needs a fallback to tab_name if there is no label set.

Thanks, fixed in the latest version.

  • Like 1

Share this post


Link to post
Share on other sites

Great idea and implementation, even though I could live with a mouse dragging - I know it would be a tough task, so it's NOT a feature request 🙂 

I played with it and left-aligning the inputs would disable the "jump" when the width value is changed via mouse (after each click on the number input spinner you have to move the mouse a bit). Also note that the inputs and names are in one line that makes the "editor" more compact.

ftw-left-aligned.thumb.png.51e5a76dbbbc88ea67cdc5ca15eb4629.png

Unfortunately the module is not compatible with aos_column_break, but I don't expect the module to support it as it would be really hard. For example, the corresponding page looks like this with the above template:

pageeditscreen.thumb.png.8226ef1b29c16afe8b8e4bf09f67e4ac.png

In theory it would be not that hard to support the "main" tab but additional aos columns can set inside tabs which would be a nightmare to deal with 🙂

  • Like 2

Share this post


Link to post
Share on other sites
33 minutes ago, tpr said:

I played with it and left-aligning the inputs would disable the "jump" when the width value is changed via mouse

That's a good point, thanks. Have changed to left alignment in v0.1.5.

34 minutes ago, tpr said:

Also note that the inputs and names are in one line that makes the "editor" more compact.

Not sure I want to make this change as if the show original field width config option is enabled it makes the label a bit disconnected from the input, and for longer field names in narrower columns (esp. on narrower screens) it increases the likelihood of the field name not fitting within the column width. Having the field label break to underneath the input wouldn't be great. So I'm thinking the costs aren't worth the benefit of slightly more efficient use of vertical space. But if others would prefer everything on a single line I'm willing to reconsider.

38 minutes ago, tpr said:

In theory it would be not that hard to support the "main" tab but additional aos columns can set inside tabs which would be a nightmare to deal with 🙂

Yeah, not sure I'm up for tackling that, but if you're tinkering around some time and find a solution that would be cool. 🙂

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, Robin S said:

Not sure I want to make this change as if the show original field width config option is enabled it makes the label a bit disconnected from the input, and for longer field names in narrower columns (esp. on narrower screens) it increases the likelihood of the field name not fitting within the column width. Having the field label break to underneath the input wouldn't be great. So I'm thinking the costs aren't worth the benefit of slightly more efficient use of vertical space.

Yep, that's true. How about making this as an option? Most of the time work on templates is done on wide screen. Also, some might prefer to have fieldsets on the main screen, not on separate tabs, so I would make this configurable too. Just an idea, not a feature request.

Share this post


Link to post
Share on other sites

Maybe enabled only on larger screens with @media queries?

Share this post


Link to post
Share on other sites

Thanks for this helper module, it works great. The only issue I see in my case is that the total percentage width of the rows only equals:

2 items per row - 92%.

3 items per row - 86%

Any more than that and the field falls back down. Other than that its awesome, many thanks.

Running v0.1.5 , Processwire 3.0.1.1.8, Firefox browser, wamp on windows 7

Edited by breezer
added more description to the issue

Share this post


Link to post
Share on other sites
4 hours ago, breezer said:

The only issue I see in my case is that the total percentage width of the rows only equals:

2 items per row - 92%.

3 items per row - 86%

Any more than that and the field falls back down.

Sounds like a CSS box-sizing issue. Are you using an unmodified core admin theme? All three core admin themes apply box-sizing: border-box to all elements so I'm puzzled why that wouldn't be working in your case. Maybe you can use your browser dev tools to investigate?

  • Like 1

Share this post


Link to post
Share on other sites

My setup is non modified PW dev and uikit admin theme. I basically just edited the existing user template, and moved the role tab last in the sort since it doesn't show during profile edit. Then go to edit my profile to check the fields. All the items are pushed far left and there is a space on the right of the column:

| [ Field One ] [Field Two]     |

| [ Field One ] [ Field Two ] [ Field Three ]     |

What am I looking for when I use the dev tools, css issues are pretty much out of my realm lol

 

Share this post


Link to post
Share on other sites
5 minutes ago, breezer said:

Then go to edit my profile to check the fields. All the items are pushed far left and there is a space on the right of the column

Are we talking about layout issues in the "Field widths" field that TemplateFieldWidths adds to the Edit Template screen...

2018-11-27_103318.png.78732f44e610108b5958e3ba6394f56d.png

...or layout issues when you are editing a page/profile?

2018-11-27_103416.png.63fd709c26e1d5bfb9a7d2e64e2ef5e6.png 

Because TemplateFieldWidths doesn't have anything to do with the latter - the module just adds a quicker way to define field widths. You can check by uninstalling TemplateFieldWidths and seeing if you still have layout issues when editing a page/profile.

If it's the latter problem you could ask a question one of the main support forums, but also check this loooong GitHub issue about column widths in AdminThemeUikit: https://github.com/processwire/processwire-issues/issues/480
Personally I recommend the following config option: Modules > Core > AdminThemeUikit > Layout + interface > Inputfield column widths > Percentage-based widths

Share this post


Link to post
Share on other sites
Quote

Personally I recommend the following config option: Modules > Core > AdminThemeUikit > Layout + interface > Inputfield column widths > Percentage-based widths

Yes that feature is enabled. Here is what I get from the following setup:

fieldwidth_1.jpg.af9c2b0cf628e411f323d0986bbd455c.jpg

fieldwidth_2.jpg.8ccb0db40a69842614a77a51563f9a05.jpg

fieldwidth_3.jpg.fdab8c9daa6797470591c21182be4cf5.jpg

fieldwidth_4.jpg.1381ccfb049bc4e08bb04df2c9a7e92e.jpg

 

Share this post


Link to post
Share on other sites

@breezer, like I said, your issue is not related to this module and you can confirm this by uninstalling TemplateFieldWidths.

But your admin layout looks non-standard - compare with my screenshot above which does not have the grey background or space between inputfields. Maybe this is caused by some non-default option in AdminThemeUikit or you have interference from some non-core CSS somewhere. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Mithlesh
      Changing it to null
    • By Mithlesh
      Hi, I have one URL - writerrelocations.com/contact-now/

      I have one issue where my header Image is appearing again after the contact form, for your reference:



      I have checked my processwire template section where have not added any Image field besides Header Image, attaching the same for the reference:




      PLEASE help me to get rid of the image below contact form

      Waiting for the swift response!

      Thanks
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-08-08
      2019-06-15
      2019-06-02
      2019-05-25
      If you are interested, you can test the current state of development:
      https://github.com/gadgetto/SnipWire
      Please note that the software is not yet intended for use in a production system (alpha version).
      If you like, you can also submit feature requests and suggestions for improvement. I also accept pull requests.
      ---- INITIAL POST FROM 2019-05-25 ----
      I wanted to let you know that I am currently working on a new ProcessWire module that fully integrates the Snipcart Shopping Cart System into ProcessWire. (this is a customer project, so I had to postpone the development of my other module GroupMailer).
      The new module SnipWire offers full integration of the Snipcart Shopping Cart System into ProcessWire.
      Here are some highlights:
      simple setup with (optional) pre-installed templates, product fields, sample products (quasi a complete shop system to get started immediately) store dashboard with all data from the snipcart system (no change to the snipcart dashboard itself required) Integrated REST API for controlling and querying snipcart data webhooks to trigger events from Snipcart (new order, new customer, etc.) multi currency support self-defined/configurable tax rates etc. Development is already well advanced and I plan to release the module in the next 2-3 months.
      I'm not sure yet if this will be a "Pro" module or if it will be made available for free.
      I would be grateful for suggestions and hints!
      (please have a look at the screenshots to get an idea what I'm talking about)
       




    • By apeisa
      Update 31.7.2019: AdminBar is now maintained by @teppo. Modules directory entry has been updated, as well as the "grab the code" link below.
      ***
      Latest screencast: http://www.screencas...73-ab3ba1fea30c
      Grab the code: https://github.com/teppokoivula/AdminBar
      ***
      I put this Adminbar thingy (from here: http://processwire.c...topic,50.0.html) to modules section and to it's own topic.
      I recorded quick and messy screencast (really, my first screencast ever) to show what I have made so far. You can see it from here: http://www.screencas...18-1bc0d49841b4
      When the modal goes off, I click on the "dark side". I make it so fast on screencast, so it might seem a little bit confusing. Current way is, that you can edit, go back to see the site (without saving anything), continue editing and save. After that you still have the edit window, but if you click "dark side" after saving, then the whole page will be reloaded and you see new edits live.
      I am not sure if that is best way: there are some strengths in this thinking, but it is probably better that after saving there shouldn't be a possibility to continue editing. It might confuse because then if you make edits, click on dark side -> *page refresh* -> You lose your edits.
      ***
      When I get my "starting module" from Ryan, I will turn this into real module. Now I had to make some little tweaks to ProcessPageEdit.module (to keep modal after form submits). These probably won't hurt anything:
      if($this->redirectUrl) $this->session->redirect($this->redirectUrl); if(!empty($_GET['modal'])) $this->session->redirect("./?id={$this->page->id}&modal=true"); // NEW LINE else $this->session->redirect("./?id={$this->page->id}");   and...
      if(!empty($_GET['modal'])) { $form->attr('action', './?id=' . $this->id . '&modal=true'); } else { $form->attr('action', './?id=' . $this->id); // OLD LINE }  
×
×
  • Create New...