Templates and icons
Everything Forma prints inside a grid is a template your theme can replace.
Override a template
- Find the file in the plugin’s
templates/folder, for exampletemplates/notices/empty.php. - Copy it to
your-theme/forma/at the same path:your-theme/forma/notices/empty.php. - Edit the copy. Forma uses it from now on, and plugin updates leave it alone.
Example: the message an empty grid shows, with a link added. The template gets $message and $config:
<?php // your-theme/forma/notices/empty.php ?> <p class="my-empty"> <?php echo esc_html( $message ); ?> <a href="<?php echo esc_url( home_url( '/contact/' ) ); ?>"><?php esc_html_e( 'Ask us', 'my-theme' ); ?></a> </p>
Forma prints the grid, each item’s cell and each control’s outer element itself, so a template can’t lose the classes the script needs. A template holds only what goes inside.
What you can override
| Folder | Templates |
|---|---|
grid/ | wrapper.php (grid, toolbar and pagination together), grid.php, item.php, link-start.php, link-end.php |
skins/ | One folder per card style: skin.php, plus style.css and script.js if it has them |
filters/, search/, sort/, pagination/ | One folder per style of the control, as in skins/ |
item-parts/ | The parts a card prints with forma_item_part(): image, video, title, terms, tags, date, count, excerpt |
lightbox/ | item-data.php: an item’s image and caption for the lightbox |
notices/ | empty.php (nothing matches), notice.php and part-off.php (notes only editors see) |
preview/ | page.php (the editor’s preview frame), placeholder.php (a stand-in card while a skin is missing) |
icons/ | {name}.svg: the card arrow, the pagination chevrons, the lightbox buttons |
If you copy the template of a built-in style, such as skins/default/skin.php, your copy gets none of the plugin’s look: no is-style-{id} class and no plugin style.css. Put a style.css of your own next to it.
Icons
Templates print icons with forma_icon( 'chevron-left' ), which reads icons/chevron-left.svg, your theme’s copy first. To change an icon, save an SVG with the same name in your-theme/forma/icons/.
To change one in code, use the forma_icon filter:
add_filter( 'forma_icon', function ( $svg, $name, $class ) {
if ( 'chevron-left' === $name ) {
return '<svg class="' . esc_attr( $class ) . '" viewBox="0 0 24 24" aria-hidden="true"><path d="M15 6l-6 6 6 6" fill="none" stroke="currentColor" stroke-width="2"/></svg>';
}
return $svg;
}, 10, 3 );