pmarki

module
General site settings module

46 posts in this topic

This module provides a solution for keeping various site settings in one place (titles, slogans, api keys, emails, addresses, etc.).

Features

- Admin can create unlimited number of settings
- Settings can be grouped
- Admin can set setting label, notes, property name, field width and type
- Settings can be of type text, checkbox, radios, select, email, url, integer

How to use

In module configuration create as many settings as needed. Customize their label, type, width and provide a name you want to use in a template files (property name). After that admin can set those  settings on "General Settings" page in "Setup" section.
Every time you wish to output eg. site name you can use $settings->site_name or wire('settings')->site_name or $settings->option2 to get value of 'Check it' as seen on the first screenshot. (Checked checkbox returns 1).
You can change global name ($settings) to something else in module configuration.

To get basic markup with all settings and their values use $settings->render(), usefull to check returning values (esp. select/radios - their values are sanitized as page names).

Current limitation:
-no way to change order of settings,
-new settings can only be added at the bottom.

Multilanguage

To make fields multilanguage aware create a field with a same property name with '_languageName' appended. Example: Your site has two languages: default and french, create site_title and site_title_french fields. Put in a template $settings->site_title. If a user has set french language, this module output site_title_french, otherwise site_title. Please notice that render() function is not language aware.

https://github.com/pmarki/ProcessGeneralSettings

Screenshot_20160920_110011.pngScreenshot_20160830_180429.png

Edited by pmarki
new features added
10 people like this

Share this post


Link to post
Share on other sites

I'm using my MultiValueTextformatter module for such things, added to the Home page. Works fine, though it's for the developer only, not for the client because he could easily mess things up. If I use an InputfieldTextaraeaLanguage then it's multilanguage too - btw, is your module multilang capable?

I have another idea in mind for such a module that would heavily depend on JavaScript (namely Vue.js). It would be responsible for the UI, all settings would be saved as one JSON.

1 person likes this

Share this post


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

I'm using my MultiValueTextformatter module for such things, added to the Home page. Works fine, though it's for the developer only, not for the client because he could easily mess things up. If I use an InputfieldTextaraeaLanguage then it's multilanguage too - btw, is your module multilang capable?

I have another idea in mind for such a module that would heavily depend on JavaScript (namely Vue.js). It would be responsible for the UI, all settings would be saved as one JSON.

Yes, I used to use MultiValueTextformatter for this and had the same worries. Just modified it a little to have 'some kind of multilanguage support', not as convenient as built in pw, but better than nothing :rolleyes:

1 person likes this

Share this post


Link to post
Share on other sites

Multilanguage can complicate things a lot and most non-techie people doesn't even recognize that. At one of my workplaces they asked me to place 3 language flags to the header - they thought it's just as easy like that :)

2 people like this

Share this post


Link to post
Share on other sites

I have reorganize module settings, it uses JSON and ASM Select for fields, now it's possible to reorder settings, add, delete and so on. The only drawback is that it's not compatible with previous version. If you want to update, you will lose all entered  settings.

1 person likes this

Share this post


Link to post
Share on other sites

Nice! I haven't used it yet just had a quick look.

How about removing the "pencil" icon from the asm items and open the edit modal on click? I think this is the "natural" way of setting asmList item options in PW so people should be aware of that.

Share this post


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

asmList item options

Where are those options? Have I missed them so far? The only similar behavior is the action of the "drop down headers" of Repeater items (but those have the arrow like "greater-than sign") like this:

repeater-example.png

We can only drag-and-drop or delete standard asmSelect list items, at least that's what I have thought so far. Am I missing something?

Share this post


Link to post
Share on other sites

Eg when editing a template you can click on a field (asmList item) and set a few things there (overrides). Is that new to you? :) 

Share this post


Link to post
Share on other sites

Luckily, I have not had to update templates recently :P Jokes aside, yeah, now I see what you meant, but as a side note let me add that even those asmSelects have "text with links on them" and I thought you were referring to simply clicking on the bounding box itself and not on an additional element of it like the <a> in this case. The pencil icon might not be used in the ProcessWire admin in this context, but some sort of indicator is used, and generally I like these indicators, so that even newcomers can figure out the intended behavior. 

Share this post


Link to post
Share on other sites

Well if they get used to the pencil icon then when wil they learn the default PW workings? :)

There's an issue in the module: its SettingsJS.js is added not only in the module's page but every (admin) page and asmList items get the "pencil" icons. Of course clicking on them do nothing, apart from this error:

SettingsJS.js:50 Uncaught TypeError: Cannot read property 'undefined' of null

Setting line 42 to this fixes it:

if ($this->wire('user')->isLoggedin() && $this->input->get('name') == __CLASS__) {

 

3 people like this

Share this post


Link to post
Share on other sites
2 hours ago, tpr said:

How about removing the "pencil" icon from the asm items and open the edit modal on click?

I think I'll leave it as is. It's a good indicator for newcomers and obvious for advanced.

 

38 minutes ago, tpr said:

Setting line 42 to this fixes it:

Thanks, fixed

Share this post


Link to post
Share on other sites

Have you updated the module in the module directory? Update says the latest is v110.

Share this post


Link to post
Share on other sites
20 minutes ago, pmarki said:

Done, but honestly I thought it's done automatically.

It is done automatically, once a day I think (?)...However, you can always do it manually if you can't wait :-) 

Share this post


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

Hi pmarki, can I use this module for pw 3.xx version?

Yes, it works with pw3. Just updated module info and added textarea field.

2 people like this

Share this post


Link to post
Share on other sites

If only I knew how to do this...

Adding file fields isn't easy, beacuse you have to store a file somewhere. So far I haven't find a way to achieve this :(

But any advice would be appreciated :)

Share this post


Link to post
Share on other sites

I'm sorry, but I'm facing exactly the same problem. I'm no expert at all, but I guess the module has to create a new file/image field, a new template with that field assigned and finally a new page based on that template. Then this page could be used to store the image. Somehow. Maybe. :rolleyes:

Share this post


Link to post
Share on other sites

i would think that a general site settings module should just store settings, and not any files or images - if you need those just add a custom field to your settings template (?)

alternately ftp upload the image to a specific folder and then reference that file's path in the setting...

 

1 person likes this

Share this post


Link to post
Share on other sites
14 hours ago, Macrura said:

alternately ftp upload the image to a specific folder and then reference that file's path in the setting...

There's certainly nothing wrong with that approach and for sure it's quite common, but I think it is somewhat limited:

  • the customer/editor has to leave his known environment (ProcessWire backend in this case) and has to use FTP/SSH whatever
  • the referenced image is not available for image manipulations, for example: automatic creation a favicons in different solutions

Share this post


Link to post
Share on other sites

it depends - a lot of times if you are talking about a logo, that is a really specific image that might be precisely sized and optimized for display, may have light/dark versions, smaller icon version for mobile, maybe a version with a tagline, as well as possibly retina versions;

it could be something you don't want the client to have access to change.

On the other hand if you did want the client to have access to it and be able to change it, you might need a multi-image field with tags, so that you could upload all of the versions of the logo and tag them (light, dark, retina, icon or whatever). This is why i would recommend using the system's native image fields for images...

1 person likes this

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 Robin S
      I have had this module sitting in a 95% complete state for a while now and have finally made the push to get it out there. Thanks to @teppo for his Hanna Code Helper module which I referred to and borrowed from during development.
      https://github.com/Toutouwai/HannaCodeDialog
      HannaCodeDialog
      A module for ProcessWire CMS/CMF. Provides a number of enhancements for working with Hanna Code tags in CKEditor. The main enhancement is that Hanna tags in a CKEditor field may be double-clicked to edit their attributes using core ProcessWire inputfields in a modal dialog.
      Requires the Hanna Code module.
      Installation
      Install the HannaCodeDialog module using any of the normal methods.
      For any CKEditor field where you want the "Insert Hanna tag" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "HannaDropdown" to the "CKEditor Toolbar" settings field.
      Module configuration
      Visit the module configuration screen to set any of the following:
      Exclude prefix: Hanna tags named with this prefix will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Exclude Hanna tags: Hanna tags selected here will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Background colour of tag widgets: you can customise the background colour used for Hanna tags in CKEditor if you like. Dialog width: in pixels Dialog height: in pixels Features
      Insert tag from toolbar dropdown menu
      Place the cursor in the CKEditor window where you want to insert your Hanna tag, then select the tag from the "Insert Hanna tag" dropdown.

      Edit tag attributes in modal dialog
      Insert a tag using the dropdown or double-click an existing tag in the CKEditor window to edit the tag attributes in a modal dialog.

      Tags are widgets
      Hanna tags that have been inserted in a CKEditor window are "widgets" - they have a background colour for easy identification, are protected from accidental editing, and can be moved within the text by drag-and-drop.

      Options for tag attributes may be defined
      You can define options for a tag attribute so that editors must choose an option rather than type text. This is useful for when only certain strings are valid for an attribute and also has the benefit of avoiding typos.
      Add a new attribute for the Hanna tag, named the same as the existing attribute you want to add options for, followed by "__options". The options themselves are defined as a string, using a pipe character as a delimiter between options. Example for an existing attribute named "vegetables":
      vegetables__options=Spinach|Pumpkin|Celery|Tomato|Brussels Sprout|Potato You can define a default for an attribute as normal. Use a pipe delimiter if defining multiple options as the default, for example:
      vegetables=Tomato|Potato Dynamic options
      Besides defining static options as above, you can use one Hanna tag to dynamically generate options for another. For instance, you could create a Hanna tag that generates options based on images that have been uploaded to the page, or the titles of children of the page.
      Your Hanna tag that generates the options should echo a string of options delimited by pipe characters (i.e. the same format as a static options string).
      You will probably want to name the Hanna tag that generates the options so that it starts with an underscore (or whatever prefix you have configured as the "exclude" prefix in the module config), to avoid it appearing as an insertable tag in the HannaCodeDialog dropdown menu.
      Example for an existing attribute named "image":
      image__options=[[_images_on_page]] And the code for the _images_on_page tag:
      <?php $image_names = array(); $image_fields = $page->fields->find('type=FieldtypeImage')->explode('name'); foreach($image_fields as $image_field) { $image_names = array_unique( array_merge($image_names, $page->$image_field->explode('name') ) ); } echo implode('|', $image_names); Choice of inputfield for attribute
      For attributes which you have defined options for, you can choose the inputfield that is used to select from the options.
      Inputfields that support the selection of a single option are select (this is the default inputfield for attributes with options so it isn't necessary to specify it if you want it) and radios.
      Inputfields that support the selection of multiple options are selectmultiple, asmselect and checkboxes.
      You can also specify a checkbox inputfield - this is not for attributes with defined options but will limit an attribute to an integer value of 1 or 0.
      The names of the inputfield types are case-insensitive.
      Example for an existing attribute named "vegetables":
      vegetables__type=asmselect Descriptions and notes for inputfields
      You can add a description or notes to an attribute and these will be displayed in the dialog.
      Example for an existing attribute named "vegetables":
      vegetables__description=Please select vegetables for your soup. vegetables__notes=Pumpkin and celery is a delicious combination. Notes
      When creating or editing a Hanna tag you can view a basic cheatsheet outlining the HannaCodeDialog features relating to attributes below the "Attributes" config inputfield.
      Troubleshooting
      HannaCodeDialog includes and automatically loads the third-party CKEditor plugins Line Utilities and Widget. If you have added these plugins to your CKEditor field already for some purpose and experience problems with HannaCodeDialog try deactivating those plugins from the CKEditor field settings.
    • By Soma
      PageListImageLabel
      Marty requested and sponsored a new module little while ago.
      http://processwire.c...t-image-option/
      I just wanted to create a separate release thread. Many thanks to Marty for sponsoring and making this possible. This just shows how great this community is.
      So here it is the Page List Image Label module. It enables you to add thumbnails of images from the pages in the admin page tree.
      Download:
      http://modules.processwire.com/modules/page-list-image-label/
      Github: 
      https://github.com/somatonic/PageListImageLabel
      A screenshot of it in production. (old version)

    • By FIA2008
      How can I change the output of `Page::render`?
      I've created a hook before page::render, but when I set the $event->return to something else, my whole page is replaced with that value.
      For example:
       
      public function beforePageRender(HookEvent $event) { $event->return = 'blaat'; } This will cause my whole page to be nothing more than just 'blaat'.
      What I want, is that my menu, footer etc. are still visible but only the content of that page is replaced.
    • By kixe
      Today I have been running in mysql errors using @renobird s Module MarkupActivityLog which still uses mysqli Driver.
      @all developers
      Although mysqli is still supported PDO driver is the default database driver in PW since https://processwire.com/about/news/introducing-processwire-2.4/
      and its strongly recommend to all module authors to use/change-to PDO driver instead of mysqli.

      @renobird I have sent a pull request.