Jump to content

Recommended Posts

Ok, I got some nice progress here. After saving it redirects (out of the modal) and displays success message. I used Adam's tip on hooking to save and using sessions. I didn't need to use load hook, because I already had pagerender hook (or maybe it is faster with loaded hook?).

I had to redirect with javascript, because there seems to be no way to redirect out of the iFrame without js or user input. If someone knows please let me know :)

Oh, and how to I get base url? I have pretty ugly hard coding there with this line:

echo("top.location.href = \"http://localhost/processwire2{$this->session->pageSaved}\";");

There is probably something like $config->urls->base or like that?

Share this post


Link to post
Share on other sites

Adam: all the better :) Downloading now and I start to implement it right a way!

With Base url I meant this: $this->config->urls->root (so I found it)

Share this post


Link to post
Share on other sites

@apeisa: I may have to finish tooltips later on and test/debug IE6-8.

Also note: it is also no-JS working. if no JS is present, it just stays fixed & extended at [0;100], but links and all data work :)

Share this post


Link to post
Share on other sites

I actually just downloaded it, now tested and very smooth work and nice looking also while extended! Also very clean and nice coding here!

Someone wants to teach me a lesson how I create settings for this module?

Share this post


Link to post
Share on other sites
(or maybe it is faster with loaded hook?).

Page::loaded isn't what you want. That is called after every page finishes loading it's initial data and is ready for API use. It doesn't mean that the page is loaded in the browser, just that it's loaded in memory on the server. This is what you would use if you wanted to examine or modify some value on every page that gets loaded before anything else accesses it. Maybe I should rename this hook to be "ready" rather than "loaded"?

Very cool!!

Share this post


Link to post
Share on other sites
Someone wants to teach me a lesson how I create settings for this module?

Let me know what settings you want to start with, and I'll paste in an example for your settings.

Share this post


Link to post
Share on other sites

Ryan, as I see it, currently this settings are needed:


  •  
  • boolean showModal: whether edit opens modal box or goes to administration
     
  • boolean initCollapsed: whether to init collapsed or not
     
  • page administration: where to go after clicking on 'administration' (optional, pages makes most sense i think)

OT: Ryan, you as moderator should be the last one to double post :D ;D there is 'modify' button

Share this post


Link to post
Share on other sites

Sorry about the double post. This is probably the only forum I've ever used, so I don't know what the etiquette is. Consider me new to this. :)

Okay to make your module configurable, modify the class definition and add "ConfigurableModule" to it:

<?php
class AdminBar extends WireData implements Module, ConfigurableModule {

To implement this interface, we need to add a module configuration function to your AdminBar class. It takes one parameter, which is an array of data (that ProcessWire provides to it). If the module has been configured before, that will contain the settings in simple key = value format. It expects you to return a value of type InputfieldWrapper(). Since that is only documented in the source right now, I wanted to get you started with an example:

<?php

static public function getModuleConfigInputfields(array $data) {

// this is a container for fields, basically like a fieldset
$fields = new InputfieldWrapper();

// since this is a static function, we can't use $this->modules, so get them from the global wire() function
$modules = wire('modules');

// set some defaults if the values aren't already present
if(!isset($data['showModal'])) $data['showModal'] = 1; // default to checked
if(!isset($data['initCollapsed'])) $data['initCollapsed'] = 0; // default to unchecked
if(!isset($data['administration'])) $data['administration'] = wire('config')->adminRootPageID; // default to admin page

// showModal field
$field = $modules->get("InputfieldCheckbox"); 
$field->name = "showModal";
$field->label = "Show modal box?"; 
        $field->value = 1; 
$field->description = "Whether edit opens modal box or goes to administration.";
$field->attr('checked', !empty($data['showModal'])); 
$fields->add($field);

// initCollapsed field
$field = $modules->get("InputfieldCheckbox"); 
$field->name = "initCollapsed";
$field->label = "Init collapsed?"; 
        $field->value = 1; 
$field->attr('checked', !empty($data['initCollapsed'])); 
$fields->add($field);

// administration field
$field = $modules->get("InputfieldPageListSelect"); 
$field->name = "administration";
$field->label = "Where to go after clicking on 'administration'";
$field->value = $data['administration'];
$fields->add($field);

return $fields;
}

Once you've put this in there, you can go configure your module in the admin by clicking "Modules" and then clicking on your AdminBar module. You should now see the fields ready to configure.

Share this post


Link to post
Share on other sites

Ryan, Adam: thanks again!

I just implemented Adam's UI and I dive into these settings next.

Few questions (not important at this point, but later):

  • Date formatting - is there global settings for this?
  • Language - best practice to offer different languages for this module?

Share this post


Link to post
Share on other sites

  • Date formatting - is there global settings for this?

There isn't. But the current practice is to use either SQL date format in places where the date need to be a fixed length and/or sortable with other dates (like in a table), and to use "January 27, 2011" or "Jan 27, 2011" format anywhere else. I believe these formats are fairly universal, though correct me if I'm wrong.

  • Language - best practice to offer different languages for this module?

This is to be determined, but on the roadmap. I think that Adam is giving this some thought, as am I, and all suggestions are welcome.

Thanks,

Ryan

Share this post


Link to post
Share on other sites

There isn't. But the current practice is to use either SQL date format in places where the date need to be a fixed length and/or sortable with other dates (like in a table), and to use "January 27, 2011" or "Jan 27, 2011" format anywhere else. I believe these formats are fairly universal, though correct me if I'm wrong.

In Finland we never use dates like "Tam 27, 2011", it is almost always "27.1.2011" and sometimes "27. tammikuuta 2011" or "Tammikuu 27. 2011". I think there is nothing universal to what comes to localisation :D

Is there any best practice to give some general constants for a whole site? Ie. in AdminBar I could try to read some site wide setting for default date formatting -> if there is none, then use module default. It wouldn't be wise to create date formatting as a module setting, wouldn't it? That would create situations where there is a lot of configuration to be made if site is using many modules (not sure though) - also every module that displays dates (or other local stuff) should provide settings for customizing localisation.

Very interested to hearing Adam's thoughts on languages.

Of course considering the "hands-on" nature of PW this isn't always an issue (easy to format things just the way you like on templates).

Share this post


Link to post
Share on other sites
In Finland we never use dates like "Tam 27, 2011", it is almost always "27.1.2011" and sometimes "27. tammikuuta 2011" or "Tammikuu 27. 2011". I think there is nothing universal to what comes to localisation Cheesy

Sorry, my bad. I learn something new every day. I'm admittedly ignorant on this matter (I live in the US, in backwoods Georgia, after all).

Given what you've mentioned, I'm adding a new $config->dateFormat to the PW2 source. What do you suggest would be a good default? Something universal doesn't exist, but what would be the closest to something universal to serve as a default?

I would like to talk more with Adam and you about more localization options for PW2 (maybe we can start a new thread soon).

Share this post


Link to post
Share on other sites

Ryan: no worries. Localization is important thing and it would be nice to have clean and simple solution to that also.

Question: module settings worked nicely, but how I read those values? :)

Share this post


Link to post
Share on other sites

It's getting near the end of the work day and I'm forgetting crucial details. :) To read this values, they will be automatically set in your AdminBar instance. So anywhere in that class, you should be able to just reference it like: $this->showModal, and so on. If the value is not set or doesn't exist, it will just be null. If that's the case, then you should use some default value, because it means the module has never been configured. Or you could set them up in a __construct method. The constructor is of course executed before PW2 sets any values to the module. Whereas the init() method is called after PW2 sets values to the module. So you might setup your defaults like this:

public function __construct() {
    $this->showModal = true; 
}

No need to define a separate showModal var in your class, because WireData is already handling that for you behind the scenes...

Share this post


Link to post
Share on other sites

Hmm... $this->showModal returns 1, no matter if it is checked or not?

Share this post


Link to post
Share on other sites

You are right. I'm figuring it out now... you the first person to develop a module, and this is only the 3rd or 4th configurable module ever, so I'm getting up to speed myself. :) I'll reply shortly.

Share this post


Link to post
Share on other sites

Looks like you've found a bug! I will work to get this fixed for tomorrow. Sorry for the inconvenience. Turns out this is the first configurable module of it's type, so it's not come up before. But I think it will be an easy fix.

Share this post


Link to post
Share on other sites

No worries Ryan. This have been so much fun so far and big thanks for all your help! Dunno what my wife thinks about my late night coding after few weeks... :)

There is now first version to try out for you guys! No new features yet (only page editing and link to admin & logout), but this has super nice UI by adamkiss.

http://www.monoliitti.com/misc/AdminBar.zip

Remember: requires latest version from master branch. Installation is super simple: extract files from zip to: /site/modules/AdminBar/ and then through admin -> modules -> install (easy to find, since it will be first module on the list, good name ;))

There are some settings on module admin, but they aren't working yet (as you can read from above).

Share this post


Link to post
Share on other sites

Thanks, I can't wait to check this out! We are headed to dinner, so I'm going to check when I get back. If you are still around and want to try it, here is a fixed /wire/core/Modules.php that corrects the bug (attached). I am going to go over it in more detail tomorrow. Also, I may have told you the wrong thing on setting the defaults in the getModuleConfigInputfields... you may be able to remove that part at the top. I'll double check on the proper syntax either tonight or tomorrow, and then get started on the module documentation! :)

Modules_php.zip

Share this post


Link to post
Share on other sites

Hello boys,

nice to see this thing rolling' :)

On-topic: I don't know if I'll have time to check the module out right now, but I would love to work on it, so apeisa, please, create github account for it [or I can, if you wish], so we can synchronize better. If you don't have account / haven't work with git before, try some nice GUI for it and just dive in as I did – i still no almost nothing about it and love it already.

Off-topic: I'm currently working on new UX / UI design for PW administration – it's quite well thought out, brings some new stuff, some 'nice-somebody-thought-of-this' moments and nice design too, however, I have so much work [some of it will be brought back to PW though!] that I can't do everything at once!

From the things I would like to introduce [and some already mentioned to ryan]:

  • Text & description of field configurable in template, so you can re-use fields with better description for clients
  • a little better managment of content
  • multilinguality – it's almost finished (how it will work), I have to implement it into design (not finished) and talk to ryan how to do it
  • 'add another' – I would love to have a nice button after you save a page to have quick option of adding another
  • partials/strings system to manage little pieces of text needed anywhere in templates (+1 on multilinguality and convenience)

There is much more in little and big stuff, but basically I'm trying to translate the great PHP workflow into UX/UI.

Share this post


Link to post
Share on other sites

Thanks, I can't wait to check this out! We are headed to dinner, so I'm going to check when I get back. If you are still around and want to try it, here is a fixed /wire/core/Modules.php that corrects the bug (attached).

Thanks Ryan. I go to bed now, but I will continue on weekend.

I don't know if I'll have time to check the module out right now, but I would love to work on it, so apeisa, please, create github account for it [or I can, if you wish], so we can synchronize better. If you don't have account / haven't work with git before, try some nice GUI for it and just dive in as I did – i still no almost nothing about it and love it already.

I have used SVN much more than Git. I have tried Git few times, always liked it but never had enough reason to start using it in real project. But maybe now: https://github.com/apeisa/AdminBar

Share this post


Link to post
Share on other sites

Not working for me...I've installed it but i cannot see the bar...

Thanks for installing and sorry to hear about problems. Do you have installed latest branch from here: https://github.com/ryancramerdesign/ProcessWire/archives/master

If you do, can you paste source code of your page (some front end page and when admin is logged in)?

Share this post


Link to post
Share on other sites

Me neither – I've installed it, but it doesn't show anything. The reason, however, is in this line:

 $event->return = str_ireplace('</body>', $out, $event->return);

$event->return is empty in my case.

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 gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...