Jump to content

Featured Replies

Posted

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?

  • Author

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. 

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.

  • Author

baroness von sketch thank you GIF

Recently Browsing 0

  • No registered users viewing this page.