Tired of massive amounts of SVG code in your templates? So were we. With the ability to view your SVGs in the control panel, and implement them with a convenient one-click copy, implementing SVGs into your ExpressionEngine template has just gotten a whole lot easier (and cleaner).
- Set Config Variable.
- Upload SVGs.
- Use the add-on.
Set the $config['rd_svg_icons_folder']
config variable in system/user/config/config.php to the location you will be storing your SVGs.
Example: $config['rd_svg_icons_folder'] = $basePath .'/build/svgs/';
Add/Upload SVGs to the directory specified in the config variable.
Note: The add-on does a recurisve traverse of the directory so you should be able to add as many sub directories as you would like to keep the SVGs organized.
You should now be able to navigate the add-on in ExpressionEngine to view your SVG library. In order to implement the SVG in your template simply click on the SVG Icon to copy it to your clipboard, and then paste it into your template.
You can also manually implement the tag without the need to navigate to the add-on in the control panel using the following code.
{exp:rd_svg_icons:icon name='my-svg-name' path='path/to/svg'}
name: Required. This is simply the name of the svg file without the .svg extension.
path: Optional-ish. This is the path to the SVG relative to your config variable. So if the path to my SVG is path/to/site/assets/svgs/directory/name.svg
and my config variable is set to path/to/site/assets/svgs/
, then the value for my path parameter would be directory/
. If your SVG is at the root level of your config variable, no path is required.