1

I am trying to create my own theme and I see from cassiopeia theme

$wa->usePreset('template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'))

When I tried to use the same as in my template

$wa->usePreset('libs');

Its throwing error

$wa->useStyle('libs');

works fine.

Can someone explain the difference between usePreset and useStyle, and when to use?

1 Answer 1

3

A useStyle('libs') will include or load in your page a Web Asset with a type of CSS named libs that has been previously registered either dynamically or as part of the components joomla.asset.json file.

A Preset is a collection or profile of .css and .js Web Assets(definitions) that have been registered, normally in the joomla.asset.json file, and the usePreset command will load all of the .css and .js files defined in the preset definitionin your page.

I found this a good explanation of how to use Web Assets in a component that might be helpful in you understanding what is going on, https://www.dionysopoulos.me/book/concepts-webassetmanager.html

You will find the joomla.asset.json files for each extension, including templates in the ../media/exetension_name directories

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.