Hello,
I am building a new template. It's my first template and I can't figure out how to load the asset files on the header. Template is installed correctly and everything else is working fine but I can see at the inspection of the template code that the css and js are not linked in the header. I have done everything properly and I am gonna show below how i structured it. What could be wrong?
File structure:
templates/hyer
index.php
joomla.asset.json
templateDetails.xml
media/templates/site/hyer
css
-template.css
-template.min.css
-template.min.css.gz
images
js
scss
-template.scss
templateDetails.xml:joomla.asset.json:index.php:
I am building a new template. It's my first template and I can't figure out how to load the asset files on the header. Template is installed correctly and everything else is working fine but I can see at the inspection of the template code that the css and js are not linked in the header. I have done everything properly and I am gonna show below how i structured it. What could be wrong?
File structure:
templates/hyer
index.php
joomla.asset.json
templateDetails.xml
media/templates/site/hyer
css
-template.css
-template.min.css
-template.min.css.gz
images
js
scss
-template.scss
templateDetails.xml:
Code:
<media destination="templates/site/hyer" folder="media"> <folder>js</folder> <folder>css</folder> <folder>scss</folder> <folder>images</folder> </media>
Code:
{"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json", "name": "hyer", "version": "1.0", "description": "This file contains details of the assets used by hyer template.", "license": "GPL-2.0-or-later", "assets": [ { "name": "template.hyer.customcss", "description": "The custom css style to use. Must be placed in media/templates/site/joomstarter/css/user.css", "type": "style", "uri": "custom.css" }, { "name": "template.hyer.defaultcss", "description": "The default css style to use.", "type": "style", "uri": "template.min.css", "dependencies": [ "fontawesome" ] }, { "name": "template.hyer.defaultscript", "description": "The file containing the javascript for this template.", "type": "script", "uri": "template.js", "attributes" : { "defer": true }, "dependencies": [ "core" ] } ]}
Code:
$wa = $this->getWebAssetManager();$wa->useStyle('template.hyer.defaultcss');$wa->useScript('template.hyer.defaultscript');<!DOCTYPE html><html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"><head> <jdoc:include type="metas" /> <jdoc:include type="styles" /> <jdoc:include type="scripts" /></head>
Statistics: Posted by sirick — Wed Jan 10, 2024 1:02 pm