Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2616

Templates for Joomla! 4.x • Can't load asset files

$
0
0
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:

Code:

<media destination="templates/site/hyer" folder="media">        <folder>js</folder>        <folder>css</folder>        <folder>scss</folder>        <folder>images</folder>    </media>
joomla.asset.json:

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"      ]    }  ]}
index.php:

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



Viewing all articles
Browse latest Browse all 2616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>