opentype Posted August 14, 2022 Posted August 14, 2022 I know how to dynamically add CSS saved as part of the theme. {{\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'something.css', 'someapp', 'front' ) );}} But how can I do the same for Pages CSS files created at ACP → Pages → Templates → CSS? Anyone knows?
opentype Posted August 15, 2022 Author Posted August 15, 2022 To put this in perspective: I have a Pages database where each record needs to get its own CSS. So far, I created those files in ”Theme → cms → front → custom” but IPS has removed that ability with 4.7. So now I need an alternative way to create and call custom CSS from a template.
Martin A. Posted August 16, 2022 Posted August 16, 2022 If you know the ID of each CSS file you can do this {{$key = 10;}} {{$css = NULL; try { $css = (string) \IPS\File::get( 'cms_Pages', \IPS\cms\Templates::load( $key )->_file_object )->url; } catch ( \Exception ) {} }} {{if $css !== NULL}} {{\IPS\Output::i()->cssFiles[] = $css;}} {{endif}} If you want to load them by filename and group you'd have to either query for it, or hook into \IPS\cms\Templates and create your own helper method. load() will only accept template_id or template_key, but template_key also contains the id. opentype and Meddysong 1 1
Recommended Posts