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