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 ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      // Add your custom path inside ready or init function, didn't tested outside Mystique::add('your-configs-path'); All config files need to return a php array like examples.
      Same as ProcessWire Inputfield Api, only difference is set and showIf usage
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By angelo, italy
      Hi guys... I love pw!
      I'm trying to update a template of the multilanguagge website. I created a field, i called it "headimage" and I added it to the home template. .. . But I can t see any image!!! Where is the issue??
      Thanks
      my friends
       
    • By Robin S
      File Info
      A textformatter module for ProcessWire. The module can add information to local Pagefile links in two ways:
      As extra markup before, within or after the link As data attributes on the link (handy if you want to use a Javascript tooltip library, for instance) Screenshots
      Module config

      Example of output

      Installation
      Install the File Info module.
      Add the textformatter to one or more CKEditor fields.
      Configuration
      Add markup action (and general)
      Select "Add markup to links" Select the Pagefile attributes that will be retrieved. The attribute "filesizeStrCustom" is similar to the core "filesizeStr" attribute but allows for setting a custom number of decimal places. If you select the "modified" or "created" attributes then you can define a date format for the value. Enter a class string to add to the links if needed. Define the markup that will be added to the links. Surround Pagefile attribute names in {brackets}. Attributes must be selected in the "Pagefile attributes" section in order to be available in the added markup. If you want include a space character at the start or end of the markup then you'll need >= PW 3.0.128. Select where the markup should be added: prepended or appended within the link, before the link, or after the link. Add data attributes action
      Select "Add data attributes to links" Select the Pagefile attributes that will be retrieved. These attributes will be added to the file links as data attributes. Attributes with camelcase names will be converted to data attribute names that are all lowercase, i.e. filesizeStrCustom becomes data-filesizestrcustom. Hook
      If you want to customise or add to the attributes that are retrieved from the Pagefile you can hook TextformatterFileInfo::getFileAttributes(). For example:
      $wire->addHookAfter('TextformatterFileInfo::getFileAttributes', function(HookEvent $event) { $pagefile = $event->arguments(0); $page = $event->arguments(1); $field = $event->arguments(2); $attributes = $event->return; // Add a new attribute $attributes['sizeNote'] = $pagefile->filesize > 10000000 ? 'This file is pretty big' : 'This file is not so big'; $event->return = $attributes; });  
      https://github.com/Toutouwai/TextformatterFileInfo
      https://modules.processwire.com/modules/textformatter-file-info/
    • By Robin S
      Access By Query String
      Grant/deny access to pages according to query string.
      Allows visitors to view protected pages by accessing the page via a special URL containing an "access" GET variable. This allows you to provide a link to selected individuals while keeping the page(s) non-viewable to the public and search engines. The recipients of the link do not need to log in so it's very convenient for them.
      The view protection does not provide a high level of security so should only be used for non-critical scenarios. The purpose of the module was to prevent new websites being publicly accessible before they are officially launched, hence the default message in the module config. But it could be used for selected pages on existing websites also.
      Once a visitor has successfully accessed a protected page via the GET variable then they can view any other page protected by the same access rule without needing the GET variable for that browsing session.
      Superusers are not affected by the module.
      Usage
      Install the Access By Query String module.
      Define access rules in the format [GET variable]??[selector], one per line.
      As an example the rule...
      rumpelstiltskin??template=skills, title~=gold ...means that any pages using the "skills" template with the word "gold" in the title will not be viewable unless it is accessed with ?access=rumpelstiltskin in the URL. So you could provide a view link like https://domain.com/skills/spin-straw-into-gold/?access=rumpelstiltskin to selected individuals.
      Or you could limit view access to the whole frontend with a rule like...
      4fU4ns7ZWXar??template!=admin You can choose what happens when a protected page is visited without the required GET variable:
      Replace the rendered markup Throw a 404 exception If replacing the rendered markup you can define a meta title and message to be shown. Or if you want to use more advanced markup you can hook AccessByQueryString::replacementMarkup().
      $wire->addHookAfter('AccessByQueryString::replacementMarkup', function(HookEvent $event) { // Some info in hook arguments if needed... // The page that the visitor is trying to access $page = $event->arguments(0); // An array of access keys that apply to the page $access_keys = $event->arguments(1); // The title $title = $event->arguments(2); // The message $message = $event->arguments(3); // Return some markup $event->return = 'Your markup'; }); Screenshot

       
      https://github.com/Toutouwai/AccessByQueryString
      https://modules.processwire.com/modules/access-by-query-string/
    • By horst
      Wire Mail SMTP

      An extension to the (new) WireMail base class that uses SMTP-transport

      This module integrates EmailMessage, SMTP and SASL php-libraries from Manuel Lemos into ProcessWire. I use this continously evolved libraries for about 10 years now and there was never a reason or occasion not to do so. I use it nearly every day in my office for automated composing and sending personalized messages with attachments, requests for Disposition Notifications, etc. Also I have used it for sending personalized Bulkmails many times.

      The WireMailSmtp module extends the new email-related WireMail base class introduced in ProcessWire 2.4.1 (while this writing, the dev-branch only).
       
      Here are Ryans announcement.



      Current Version 0.3.1
      get it from the Modules Directory Install and Configure

      Download the module into your site/modules/ directory and install it.

      In the config page you fill in settings for the SMTP server and optionaly the (default) sender, like email address, name and signature.
      You can test the smtp settings directly there. If it says "SUCCESS! SMTP settings appear to work correctly." you are ready to start using it in templates, modules or bootstrap scripts.


      Usage Examples
      The simplest way to use it:
      $numSent = wireMail($to, $from, $subject, $textBody); $numSent = wireMail($to, '', $subject, $textBody); // or with a default sender emailaddress on config page This will send a plain text message to each recipient.
       
      You may also use the object oriented style:
      $mail = wireMail(); // calling an empty wireMail() returns a wireMail object $mail->to($toEmail, $toName); $mail->from = $yourEmailaddress; // if you don't have set a default sender in config // or if you want to override that $mail->subject($subject); $mail->body($textBody); $numSent = $mail->send(); Or chained, like everywhere in ProcessWire:
      $mail = wireMail(); $numSent = $mail->to($toEmail)->subject($subject)->body($textBody)->send(); Additionaly to the basics there are more options available with WireMailSmtp. The main difference compared to the WireMail BaseClass is the sendSingle option. With it you can set only one To-Recipient but additional CC-Recipients.
      $mail = wireMail(); $mail->sendSingle(true)->to($toEmail, $toName)->cc(array('person1@example.com', 'person2@example.com', 'person3@example.com')); $numSent = $mail->subject($subject)->body($textBody)->send(); The same as function call with options array:
      $options = array( 'sendSingle' => true, 'cc' => array('person1@example.com', 'person2@example.com', 'person3@example.com') ); $numSent = wireMail($to, '', $subject, $textBody, $options); There are methods to your disposal to check if you have the right WireMail-Class and if the SMTP-settings are working:
      $mail = wireMail(); if($mail->className != 'WireMailSmtp') { // Uups, wrong WireMail-Class: do something to inform the user and quit echo "<p>Couldn't get the right WireMail-Module (WireMailSmtp). found: {$mail->className}</p>"; return; } if(!$mail->testConnection()) { // Connection not working: echo "<p>Couldn't connect to the SMTP server. Please check the {$mail->className} modules config settings!</p>"; return; } Following are a ...


      List of all options and features


      testConnection () - returns true on success, false on failures


      sendSingle ( true | false ) - default is false

      sendBulk ( true | false ) - default is false, Set this to true if you have lots of recipients (50+)


      to ($recipients) - one emailaddress or array with multiple emailaddresses

      cc ($recipients) - only available with mode sendSingle, one emailaddress or array with multiple emailaddresses

      bcc ($recipients) - one emailaddress or array with multiple emailaddresses

       
      from = 'person@example.com' - emailaddress, can be set in module config (called Sender Emailaddress) but it can be overwritten here

      fromName = 'Name Surname' - optional, can be set in module config (called Sender Name) but it can be overwritten here


      priority (3) - 1 = Highest | 2 = High | 3 = Normal | 4 = Low | 5 = Lowest

      dispositionNotification () or notification () - request a Disposition Notification


      subject ($subject) - subject of the message

      body ($textBody) - use this one alone to create and send plainText emailmessages

      bodyHTML ($htmlBody) - use this to create a Multipart Alternative Emailmessage (containing a HTML-Part and a Plaintext-Part as fallback)

      addSignature ( true | false ) - the default-behave is selectable in config screen, this can be overridden here
      (only available if a signature is defined in the config screen)

      attachment ($filename, $alternativeBasename = "") - add attachment file, optionally alternative basename


      send () - send the message(s) and return number of successful sent messages


      getResult () - returns a dump (array) with all recipients (to, cc, bcc) and settings you have selected with the message, the message subject and body, and lists of successfull addresses and failed addresses,


      logActivity ($logmessage) - you may log success if you want

      logError ($logmessage) - you may log warnings, too. - Errors are logged automaticaly
       
       
      useSentLog (true | false) - intended for usage with e.g. third party newsletter modules - tells the send() method to make usage of the sentLog-methods - the following three sentLog methods are hookable, e.g. if you don't want log into files you may provide your own storage, or add additional functionality here

      sentLogReset ()  - starts a new LogSession - Best usage would be interactively once when setting up a new Newsletter

      sentLogGet ()  - is called automaticly within the send() method - returns an array containing all previously used emailaddresses

      sentLogAdd ($emailaddress)  - is called automaticly within the send() method
       
      Changelog: https://github.com/horst-n/WireMailSmtp/blob/master/CHANGELOG.md
       
      LATEST UPDATE:
       
×
×
  • Create New...