Semantic icon helper for PrestaShop modules. - Maps icon names to Font Awesome or Material Icons - Auto-detects admin context (Material) vs front (FA default) - Reads icon preference from ps_mpr_config table - Theme detection for Material Icons - PHP class + JavaScript helper Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3.2 KiB
3.2 KiB
PrestaShop Icons
Semantic icon helper for PrestaShop modules.
MprIcons::get('account'); // Just works
How It Works
- Admin: Uses Material Icons (auto-detected)
- Front: Reads from
ps_mpr_configtable, defaults to Font Awesome
Setup (Module Install)
Call init() from your module's install method:
public function install()
{
MprIcons::init(); // Creates config table, detects theme icons
return parent::install();
}
This will:
- Create
ps_mpr_configtable if it doesn't exist - Detect theme icon set (checks theme.yml, assets for Material)
- Save the detected preference
PHP
use MyPrestaRocks\Icons\MprIcons;
// Just call get() - it figures out the rest
echo MprIcons::get('account');
echo MprIcons::get('cart');
echo MprIcons::get('success', 'text-green'); // With extra class
// Get raw class/name (no HTML)
$class = MprIcons::raw('edit'); // 'fa fa-pencil' or 'edit'
JavaScript
Include the script and set icon set from PHP:
// In your module
$this->context->controller->addJS($this->getLocalPath() . 'vendor/myprestarocks/prestashop-icons/js/mpr-icons.js');
Media::addJsDef(['mprIconSet' => MprIcons::getIconSet()]);
MprIcons.get('account'); // HTML string
MprIcons.create('warning'); // DOM element
MprIcons.raw('edit'); // Class/name only
Configuration
Front office icon set is stored in ps_mpr_config:
- module:
mpr_global - key:
front_icon_set - value:
fontawesomeormaterial
// Save preference
MprIcons::saveIconSet('material');
Available Icons
| Name | Font Awesome | Material |
|---|---|---|
account |
fa fa-user |
person |
cart |
fa fa-shopping-cart |
shopping_cart |
orders |
fa fa-list |
receipt_long |
success |
fa fa-check |
check |
error |
fa fa-times |
close |
warning |
fa fa-exclamation-triangle |
warning |
info |
fa fa-info-circle |
info |
edit |
fa fa-pencil |
edit |
delete |
fa fa-trash |
delete |
search |
fa fa-search |
search |
settings |
fa fa-cog |
settings |
email |
fa fa-envelope |
email |
phone |
fa fa-phone |
phone |
lock |
fa fa-lock |
lock |
logout |
fa fa-sign-out |
logout |
home |
fa fa-home |
home |
address |
fa fa-map-marker |
location_on |
truck |
fa fa-truck |
local_shipping |
credit-card |
fa fa-credit-card |
credit_card |
calendar |
fa fa-calendar |
calendar_today |
heart |
fa fa-heart |
favorite |
star |
fa fa-star |
star |
eye |
fa fa-eye |
visibility |
eye-off |
fa fa-eye-slash |
visibility_off |
close |
fa fa-times |
close |
check |
fa fa-check |
check |
plus |
fa fa-plus |
add |
minus |
fa fa-minus |
remove |
chevron-* |
fa fa-chevron-* |
chevron_* |
arrow-* |
fa fa-arrow-* |
arrow_* |
download |
fa fa-download |
download |
upload |
fa fa-upload |
upload |
refresh |
fa fa-refresh |
refresh |
spinner |
fa fa-spinner fa-spin |
hourglass_empty |
loading |
fa fa-circle-o-notch fa-spin |
autorenew |
Full list: MprIcons::list()
License
MIT