Skip to content

Instantly share code, notes, and snippets.

@somatonic
Created January 15, 2014 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save somatonic/8446801 to your computer and use it in GitHub Desktop.
Save somatonic/8446801 to your computer and use it in GitHub Desktop.
Example helper module that adds a new system variable "$helper" with a method to generate FontAwesome markup for use in templates
<?php
class MyHelper extends WireData implements Module {
/**
* getModuleInfo is a method required by all modules to tell ProcessWire about them
* @return array
*/
public static function getModuleInfo() {
return array(
'title' => 'My Helper Module',
'version'=> 1,
'summary' => 'Example Helper Module to generate FontAwesome icon markup.',
'author' => 'me',
'singular' => true,
'autoload' => true
);
}
public function init(){
$this->set("icon_prefix", "fa");
wire("fuel")->set("helper", $this);
}
public function faIcon($name, $size = ''){
if($size){
$size = " {$this->icon_prefix}-$size";
}
return "<i class='{$this->icon_prefix} {$this->icon_prefix}-$name{$size}'></i>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment