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

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip