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.
    • Field widths entered into the Template Field Widths inputfield are only applied if the Edit Template form is submitted with the Template Field Widths inputfield in an opened state.
    • "Collapsed" is the recommended setting if you think you might also use core inputs for setting field widths in a template context.
  • 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 eelkenet
      Hi! I've created a small Inputfield module called InputfieldFloatRange which allows you to use an HTML5 <input type="range" ../> slider as an InputField. I needed something like this for a project where the client needs to be able to tweak this value more based on 'a feeling' than just entering a boring old number. Maybe more people can use this so I'm hereby releasing it into the wild. 
      EDIT: You can now install it directly from the Modules directory: http://modules.processwire.com/modules/inputfield-float-range/
       
      What is it?
      The missing range slider Inputfield for Processwire. 
      What does it do?
      This module extends InputfieldFloat and allows you to use HTML5 range sliders for number fields in your templates.
      It includes a visible and editable value field, to override/tweak the value if required.  
      Features
      Min/max values Precision (number of decimals) Optional step value (Read more) Optional manual override of the selected value (will still adhere to the rules above) Configurable rounding of manually entered values (floor, round, ceil, disable) Usage
      Clone / zip repo Install FieldtypeFloatRange, this automatically installs the Inputfield Create new field of type `Float (range)` or convert an existing `Float`, `Integer` or `Text` field. To render the field's value simply echo `$page->field` Demo
      A field with Min=0, Max=1, Step=0.2, Precision=2

      Field with settings Min=0, Max=200, Step=0.25, Precision=2

       
      Todo
      Make the display-field's size configurable (will use the Input Size field setting)  Hopefully become redundant  
      Changelog
      005 (current version)
      - Fix bug where the Inputfield would not work properly within repeaters / repeater matrices
      004
      - Make rounding of manually entered values configurable (floor, round, ceil or disable)
      - Fix small JS bug when the value-display field was not displayed
      - Update README
      003
      - Code cleanup, add some ModuleInfo data & LICENSE
      - Submit to PW Modules directory (http://modules.processwire.com/modules/inputfield-float-range/)
      002
      - Fix issue where setting the step value to an empty value created problem with validation
      - Make the display-field optional
      001
      - Initial release
       
      Thanks!
       
       
    • By Gadgetto
      Status update links (inside this thread) for SnipWire development will be always posted here:
      2019-10-18
      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 adrian
      Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS

       
      Integrates and extends Nette's Tracy debugging tool and adds 35+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By adrian
      This module allows you to automatically rename file (including image) uploads according to a configurable format
      This module lets you define as many rules as you need to determine how uploaded files will be named and you can have different rules for different pages, templates, fields, and file extensions, or one rule for all uploads. Renaming works for files uploaded via the admin interface and also via the API, including images added from remote URLs.   Github: https://github.com/adrianbj/CustomUploadNames
      Modules Directory: http://modules.processwire.com/modules/process-custom-upload-names/
      Renaming Rules
      The module config allows you to set an unlimited number of Rename Rules. You can define rules to specific fields, templates, pages, and file extensions. If a rule option is left blank, the rule with be applied to all fields/templates/pages/extensions. Leave Filename Format blank to prevent renaming for a specific field/template/page combo, overriding a more general rule. Rules are processed in order, so put more specific rules before more general ones. You can drag to change the order of rules as needed. The following variables can be used in the filename format: $page, $template, $field, and $file. For some of these (eg. $field->description), if they haven't been filled out and saved prior to uploading the image, renaming won't occur on upload, but will happen on page save (could be an issue if image has already been inserted into RTE/HTML field before page save). Some examples: $page->title mysite-{$template->name}-images $field->label $file->description {$page->name}-{$file->filesize}-kb prefix-[Y-m-d_H-i-s]-suffix (anything inside square brackets is is considered to be a PHP date format for the current date/time) randstring[n] (where n is the number of characters you want in the string) ### (custom number mask, eg. 001 if more than one image with same name on a page. This is an enhanced version of the automatic addition of numbers if required) If 'Rename on Save' is checked files will be renamed again each time a page is saved (admin or front-end via API). WARNING: this setting will break any direct links to the old filename, which is particularly relevant for images inserted into RTE/HTML fields. The Filename Format can be defined using plain text and PW $page variable, for example: mysite-{$page->path} You can preserve the uploaded filename for certain rules. This will allow you to set a general renaming rule for your entire site, but then add a rule for a specific page/template/field that does not rename the uploaded file. Just simply build the rule, but leave the Filename Format field empty. You can specify an optional character limit (to nearest whole word) for the length of the filename - useful if you are using $page->path, $path->name etc and have very long page names - eg. news articles, publication titles etc. NOTE - if you are using ProcessWire's webp features, be sure to use the useSrcExt because if you have jpg and png files on the same page and your rename rules result in the same name, you need to maintain the src extension so they are kept as separate files.
      $config->webpOptions = array(     'useSrcExt' => false, // Use source file extension in webp filename? (file.jpg.webp rather than file.webp) ); Acknowledgments
      The module config settings make use of code from Pete's EmailToPage module and the renaming function is based on this code from Ryan: http://processwire.com/talk/topic/3299-ability-to-define-convention-for-image-and-file-upload-names/?p=32623 (also see this post for his thoughts on file renaming and why it is the lazy way out - worth a read before deciding to use this module). 
       
       
      NOTE:
      This should not be needed on most sites, but I work with lots of sites that host PDFs and photos/vectors that are available for download and I have always renamed the files on upload because clients will often upload files with horrible meaningless filenames like:
      Final ReportV6 web version for John Feb 23.PDF

×
×
  • Create New...