Created
January 15, 2014 23:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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