Jump to content
Martijn Geerts

Release: Font Awesome Page Label (module)

Recommended Posts

Font Awesome Page Label (almost stable version)

Yet another PageListLabel module, why?

  • Font Awesome is really awesome, hundreds of high quality icons, ready to use. (Don't we all know how cool icon fonts are.)
  • I wished to use icons in conjunction with the other PageList modules out there. (Page List Better Labels, Page List Image Label & Page List Show Page Id )
  • I wanted the possibility to style the icons individually with CSS.
  • Showing icons triggered bij template name, but can be overruled bij Page ID. (Trash Page, 404 Page not found etc.)
  • I wanted a better file or folder indication in the PageList tree.

post-577-0-13441400-1378924489_thumb.pngpost-577-0-66941000-1378926607_thumb.pngpost-577-0-56497900-1379243245_thumb.png

Download:

github

modules directory

  • Like 16

Share this post


Link to post
Share on other sites

As this Page Label module uses Javascript to insert the icons it should be compatible with most other Page List modules.

I confirm this compatibility with:

  • Page List Better Labels
  • Page List Image Label
  • Page List Show Page Id
  • Template Decorator
  • Do we have other modules.... ?

After I tried these modules I think I need the ability in this module to hide certain icons.

Say you show a image in the list (Page List Image Label), an extra icon from this module is not that nice.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for this module Martijn!

A couple minor things to mention:

You might want to limit your hook to running only when the template is 'admin'. That way it won't be attempting to insert code in regular page renders (not that it does now, but it looks to be executing on regular page renders even if it doesn't do anything). You could do that by moving your hook-attaching code to a ready() method:

public function ready() {
  if($this->page->template != 'admin') return;
  $this->addHookAfter('Page::render', $this, 'rewriteJsConfig');
  $this->addHookBefore('ProcessPageList::execute', $this, 'appendStylesScripts');
}

The other thing I wanted to mention is that you may not necessarily need to search/replace the rendered output. You can access the values that will be populated to the 'config' JS variable, anytime before render, with:

$all = $config->js(); // returns array of everything for the JS config var
$config->js('key', 'value'); // populate 'value' to variable 'key'
$value = $config->js('key'); // get existing value of 'key'

I'm not positive about what your search/replace was doing, so if I've misunderstood you can ignore this. But just wanted to pass this along in case it is applicable, as it might be more efficient to set/modify the values directly with $config->js before render, rather than search/replace after render. 

Share this post


Link to post
Share on other sites

Tnx ryan.

Had a hard fight building this module with scoping as i'm not very comfortable with OOP. 

I needed some functions to be static ( for getModuleConfigInputfields ). It was a bit of trial and error.

All points you mentioned are fixed in the latest update.

What is still unclear to me is why this module still needs a empty init() to function. 

  • Like 1

Share this post


Link to post
Share on other sites

Tnx ryan.

Had a hard fight building this module with scoping as i'm not very comfortable with OOP. 

I needed some functions to be static ( for getModuleConfigInputfields ). It was a bit of trial and error.

All points you mentioned are fixed in the latest update.

What is still unclear to me is why this module still needs a empty init() to function. 

From the module interface

/**
     * Method to initialize the module. 
     *
     * While the method is required, if you don't need it, then just leave the implementation blank.
     *
     * This is called after ProcessWire's API is fully ready for use and hooks. It is called at the end of the 
     * bootstrap process. This is before PW has started retrieving or rendering a page. If you need to have the
     * API ready with the $page ready as well, then see the ready() method below this one. 
     *
     */
    public function init();
  • Like 2

Share this post


Link to post
Share on other sites

Well, I see two in your picture, which one is Martijn and which one is Geerts?

  • Like 3

Share this post


Link to post
Share on other sites

@Martijn, this module is great!

i just tweaked it to work with the new version of Fontawesome; 

i can send you the changes or make some gists?; just some small changes here and there to get it working with the fa- class as well as using the fa class by itself to get the icons to render; also since fa is included in the admin, no @import is necessary...

while this module might seem redundant with the core fontawesome icon capabilities, there are some situations where this module is more flexible, like with having an icon on any page (based on iD) without specifying at the template level...

also, this module is much easier for me to be able to setup a whole lot of icons at once instead of opening all the templates to make changes.. and the custom CSS file in the templates folder makes it really easy to color code or otherwise add specific styling to selected icons;

i guess if people still want this module to support IE7, there should be a different version for this, which doesn't include the fonts, and just gives you the control screen for specifying the page ids, templates and font classes..

  • Like 1

Share this post


Link to post
Share on other sites

I felt the same about redundancy for this module after Ryan released Font-Awesome for the core. I didn't event thought someone was using it besides me. I did thought about a process module around Ryans way of using icons. but my available time is limited and this will be the next half year or so. 

 

IE7 support is not needed. People with IE7 can't login in the admin. (I hope/think)

Thank you for making those changes that I should have done a long time ago !

I'll PM you.

Share this post


Link to post
Share on other sites

@Martijn, cool, i sent you my version with the changes, maybe you'll see a better way of doing some things than i did!

the only thing that was bugging me about how i did it was that i had to have the 2 classes (both fa and fa-icon-name) in the config fields in the backend; perhaps there is a cleaner way of having the module code include the default class and only have the icon class in the module config screen fields;

Also i put my css in the php/css file and not in the module - i changed the css so that the icons (color, size) match the new 2.4 theme icons.

(to sum up for anyone else wondering why this module is useful in the 2.4 version, it allows you to specify icons for any page using the ID, otherwise all pages using a certain template would have the same icon; also it simplifies specifying icons for a lot of pages and templates at once and then using the css/php file in the templates directory you can change specific icons css.)

  • Like 1

Share this post


Link to post
Share on other sites

Hello Martijn,

i did something similar as my first attempt to a pw module. Now i discovered yours.

My module adds icons to the page actions (requires pw-dev labeled 2.4.4) and does not add js. It's a very quick and dirty module which uses the fotn icons of the wire core.

Please check it out on github and let me know if it can be useful to onyone except me.

https://github.com/pine3ree/AdminPageIcons

admin-page-icons.png

kind regards,

PS

the pw project leader and this community are the kindest i ever found in web development.

  • Like 3

Share this post


Link to post
Share on other sites

Hi pine3ree,

I had not the time and the computer to check out your module. ( Hardisk crash this week :'( , today I will bring my 'new' iMac to a Apple reseller in the hope it would not take long for them to fix. ) Fontawesome page label is developed a few weeks before Ryan introduced Fontawesome in the core so it's a little bit redundant now. I'm not sure where to go with this module.

I will definitely check out your module as soon i've time. You'll never know where this leads us. Thanks for checking out Font awesome Page label.

Share this post


Link to post
Share on other sites

Thank You Martijn....yes i'm working on my 1st site with pw (after so many years with SS) and i noticed Ryan's addition before getting back here.

The only addition left is the icons in the actions replacing the text and the mere possibility of using larger (fa-lg (+ fa-fw)) icons without touching the default admin styles, but let's hope Ryan add this little feature too, so i'll get rid of my 1st module as soon as possible.

Don't bother trying it....what you get is exaclty what you see in the screenshot, and as you can see i didn't even bother to send it to the pw web site module section.

sorry for your HD...if it's a SSD (i guess being a new mac) it would be the first time i heard one crashing ...and that makes me tremble too. If it's not, consider buyingone..it  really changes your life and the time you save from waiting will repay you soon enough.

kind regards to everyone.

Share this post


Link to post
Share on other sites
sorry for your HD...if it's a SSD (i guess being a new mac) it would be the first time i heard one crashing ...and that makes me tremble too. If it's not, consider buyingone..it  really changes your life and the time you save from waiting will repay you soon enough

I have a fusion drive in the mac, the rotating one failed. Just bad luck.

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 Paul Greinke
      Hi there. I wrote a custom module for one of my projects. In fact I maybe want to use my module in other projects too. In order to be variable and customizable  I need to implement some custom hooks into my module. So I can afterwards hook into the my functions in order to modify them to match the needs of the new project.
      I tried simply defining functions with the '__' prefix. But that did not work. I'm imagining something like the following:
      <?php class MyClass { public function ___someFunction() { // Do something } } // ready.php $this->addHookBefore('MyClass::someFunction', function($event) { // some customization }); Is there a way to accomplish that? 
    • By adrian
      Hi everyone,
      Here's a new module that I have been meaning to build for a long time.
      http://modules.processwire.com/modules/process-admin-actions/
      https://github.com/adrianbj/ProcessAdminActions
       
      What does it do?
      Do you have a bunch of admin snippets laying around, or do you recreate from them from scratch every time you need them, or do you try to find where you saw them in the forums, or on the ProcessWire Recipes site?
      Admin Actions lets you quickly create actions in the admin that you can use over and over and even make available to your site editors (permissions for each action are assigned to roles separately so you have full control over who has access to which actions).
       
      Included Actions
      It comes bundled with several actions and I will be adding more over time (and hopefully I'll get some PRs from you guys too). You can browse and sort and if you have @tpr's Admin on Steroid's datatables filter feature, you can even filter based on the content of all columns. 

      The headliner action included with the module is: PageTable To RepeaterMatrix which fully converts an existing (and populated) PageTable field to either a Repeater or RepeaterMatrix field. This is a huge timesaver if you have an existing site that makes heavy use of PageTable fields and you would like to give the clients the improved interface of RepeaterMatrix.
      Copy Content To Other Field
      This action copies the content from one field to another field on all pages that use the selected template.
      Copy Field Content To Other Page
      Copies the content from a field on one page to the same field on another page.
      Copy Repeater Items To Other Page
      Add the items from a Repeater field on one page to the same field on another page.
      Copy Table Field Rows To Other Page
      Add the rows from a Table field on one page to the same field on another page.
      Create Users Batcher
      Allows you to batch create users. This module requires the Email New User module and it should be configured to generate a password automatically.
      Delete Unused Fields
      Deletes fields that are not used by any templates.
      Delete Unused Templates
      Deletes templates that are not used by any pages.
      Email Batcher
      Lets you email multiple addresses at once.
      Field Set Or Search And Replace
      Set field values, or search and replace text in field values from a filtered selection of pages and fields.
      FTP Files to Page
      Add files/images from a folder to a selected page.
      Page Active Languages Batcher
      Lets you enable or disable active status of multiple languages on multiple pages at once.
      Page Manipulator
      Uses an InputfieldSelector to query pages and then allows batch actions on the matched pages.
      Page Table To Repeater Matrix
      Fully converts an existing (and populated) PageTable field to either a Repeater or RepeaterMatrix field.
      Template Fields Batcher
      Lets you add or remove multiple fields from multiple templates at once.
      Template Roles Batcher
      Lets you add or remove access permissions, for multiple roles and multiple templates at once.
      User Roles Permissions Batcher
      Lets you add or remove permissions for multiple roles, or roles for multiple users at once.
       
      Creating a New Action
      If you create a new action that you think others would find useful, please add it to the actions subfolder of this module and submit a PR. If you think it is only useful for you, place it in /site/templates/AdminActions/ so that it doesn't get lost on module updates.
      A new action file can be as simple as this:
      class UnpublishAboutPage extends ProcessAdminActions { protected function executeAction() { $p = $this->pages->get('/about/'); $p->addStatus(Page::statusUnpublished); $p->save(); return true; } } Each action:
      class must extend "ProcessAdminActions" and the filename must match the class name and end in ".action.php" like: UnpublishAboutPage.action.php the action method must be: executeAction() As you can see there are only a few lines needed to wrap the actual API call, so it's really worth the small extra effort to make an action.
      Obviously that example action is not very useful. Here is another more useful one that is included with the module. It includes $description, $notes, and $author variables which are used in the module table selector interface. It also makes use of the defineOptions() method which builds the input fields used to gather the required options before running the action.
      class DeleteUnusedFields extends ProcessAdminActions { protected $description = 'Deletes fields that are not used by any templates.'; protected $notes = 'Shows a list of unused fields with checkboxes to select those to delete.'; protected $author = 'Adrian Jones'; protected $authorLinks = array( 'pwforum' => '985-adrian', 'pwdirectory' => 'adrian-jones', 'github' => 'adrianbj', ); protected function defineOptions() { $fieldOptions = array(); foreach($this->fields as $field) { if ($field->flags & Field::flagSystem || $field->flags & Field::flagPermanent) continue; if(count($field->getFieldgroups()) === 0) $fieldOptions[$field->id] = $field->label ? $field->label . ' (' . $field->name . ')' : $field->name; } return array( array( 'name' => 'fields', 'label' => 'Fields', 'description' => 'Select the fields you want to delete', 'notes' => 'Note that all fields listed are not used by any templates and should therefore be safe to delete', 'type' => 'checkboxes', 'options' => $fieldOptions, 'required' => true ) ); } protected function executeAction($options) { $count = 0; foreach($options['fields'] as $field) { $f = $this->fields->get($field); $this->fields->delete($f); $count++; } $this->successMessage = $count . ' field' . _n('', 's', $count) . ' ' . _n('was', 'were', $count) . ' successfully deleted'; return true; } }  
      This defineOptions() method builds input fields that look like this:

      Finally we use $options array in the executeAction() method to get the values entered into those options fields to run the API script to remove the checked fields.
      There is one additional method that I didn't outline called: checkRequirements() - you can see it in action in the PageTableToRepeaterMatrix action. You can use this to prevent the action from running if certain requirements are not met.
      At the end of the executeAction() method you can populate $this->successMessage, or $this->failureMessage which will be returned after the action has finished.
       
      Populating options via URL parameters
      You can also populate the option parameters via URL parameters. You should split multiple values with a “|” character.
      You can either just pre-populate options:
      http://mysite.dev/processwire/setup/admin-actions/options?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add
      or you can execute immediately:
      http://mysite.dev/processwire/setup/admin-actions/execute?action=TemplateFieldsBatcher&templates=29|56&fields=219&addOrRemove=add

      Note the “options” vs “execute” as the last path before the parameters.
       
      Automatic Backup / Restore
      Before any action is executed, a full database backup is automatically made. You have a few options to run a restore if needed:
      Follow the Restore link that is presented after an action completes Use the "Restore" submenu: Setup > Admin Actions > Restore Move the restoredb.php file from the /site/assets/cache/AdminActions/ folder to the root of your site and load in the browser Manually restore using the AdminActionsBackup.sql file in the /site/assets/cache/AdminActions/ folder I think all these features make it very easy to create custom admin data manipulation methods that can be shared with others and executed using a simple interface without needing to build a full Process Module custom interface from scratch. I also hope it will reduce the barriers for new ProcessWire users to create custom admin functionality.
      Please let me know what you think, especially if you have ideas for improving the interface, or the way actions are defined.
       
       
    • By joshua
      ---
      Module Directory: https://modules.processwire.com/modules/privacy-wire/
      Github: https://github.com/blaueQuelle/privacywire/
      Packagist:https://packagist.org/packages/blauequelle/privacywire
      Module Class Name: PrivacyWire
      Changelog: https://github.com/blaueQuelle/privacywire/blob/master/Changelog.md
      ---
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Functional
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The data-attributes (data-type and data-category) are required to get recognized by PrivacyWire. the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button>  
      I would love to hear your feedback 🙂
      CHANGELOG
      You can find the always up-to-date changelog file here.
    • By joshua
      As we often use Matomo (former known as Piwik) instead of Google Analytics we wanted to embed Matomo not only in the template code but also via the ProcessWire backend.
      That's why I developed a tiny module for the implementation.
      The module provides the possibility to connect to an existing Matomo installation with the classical site tracking and also via the Matomo Tag Manager.
      If you have also PrivacyWire installed, you can tell MatomoWire to only load the script, if the user has accepted cookies via PrivacyWire.
      To offer an Opt-Out solution you can choose between the simple Opt-Out iFrame, delivered by your Matomo installation, or a button to choose cookies via PrivacyWire.
      You'll find the module both in the module directory and via github:
      ProcessWire Module Directory MatomoWire @ GitHub MatomoWire @ Packagist ->installable via composer require blauequelle/matomowire I'm looking forward to hear your feedback!


    • By Robin S
      If your module has a lot of config fields you might want to divide them into groups inside a tabbed interface. Here is a demonstration module showing how this can be done.
      https://github.com/Toutouwai/ModuleConfigTabs

      Thanks to @kixe for providing my starting point in this forum topic.
×
×
  • Create New...