Sonya* Posted October 19, 2021 Posted October 19, 2021 (edited) I have created Page CSS. It works on the page with database. Now I would like to include it into custom block (Plugin) based on this database. This does not work: {{\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'myfolder/general.css', 'cms', 'front' ) );}} And using a template plugin, I get 'ErrorException: template_store_missing (0)': {template="includeCSS" app="cms" group="myfolder/general" location="front" params=""} Is there any other idea of how to include Page CSS in the block or other templates? Note: I do not have any app or plugin. This is just a simple Pages database. Edited October 19, 2021 by Sonya*
Daniel F Posted October 19, 2021 Posted October 19, 2021 Custom Pages related js & css templates aren't stored in the default IPS template storage, so \IPS\Theme and the template output helper won't work here. Instead you'll have to use the \IPS\cms\Templates class where the load method accepts either the ID or the key as first param. Meddysong 1
Sonya* Posted October 19, 2021 Author Posted October 19, 2021 @Daniel F this means I have to know the ID of the Pages CSS. No way to get it just by name? I often export and import database and block templates. Do I have to edit the block template on every installation to enter the id/key of the template?
Daniel F Posted October 20, 2021 Posted October 20, 2021 Unfortunatly I can't think of any other way.
Sonya* Posted October 20, 2021 Author Posted October 20, 2021 I've ended up in adding SQL query to the block template that gets template_id from template_title, template_group and template_location.
Recommended Posts