Jump to content

Recommended Posts

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?

Posted

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. 

Posted

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...