Skip to content

Instantly share code, notes, and snippets.

@matdave
Created April 6, 2018 21:07
Show Gist options
  • Save matdave/345c12204bf96b146fff0aeef76d739c to your computer and use it in GitHub Desktop.
Save matdave/345c12204bf96b146fff0aeef76d739c to your computer and use it in GitHub Desktop.
MODX Font Awesome Selector TV
[[+icon_class:replace=`fa-==`]] <i class="[[+icon_class:replace=`fa-==icon-`]] icon icon-large"></i>
<?php
$site_url=$modx->config['site_url'];
$subject = file_get_contents($site_url .'path/to/font-awesome.css');
$pattern = '/\.(fa-(?:\w+(?:-)?)+):before\s/';
preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER);
foreach($matches as $match){
$iconclass = $match[1];
$iconselect = $modx->getChunk('FontAwesomeIcon',array('icon_class' => $iconclass)) .'==' . $iconclass;
$icons= $icons . $iconselect .'||';
}
//$icons= '--FontAwesome Icons--||' . $icons;
return ($icons);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment