How to get J4 to read template.php file Topic is solved

Be informed that this forum is not an official support forum for Joomla! 4.0. Any issues regarding Joomla! 4.0 must be reported at https://issues.joomla.org/.

Joomla 4.0 is still in Beta stage. This forum should be used for sharing information about Joomla! 4.0.

Moderator: ooffick

Forum rules
Locked
GillianBPP
Joomla! Explorer
Joomla! Explorer
Posts: 396
Joined: Wed Oct 01, 2014 10:25 am

How to get J4 to read template.php file

Post by GillianBPP » Sat Jan 12, 2019 4:50 pm

I have designed a template that is running happily on J3.9.1 with Bootstrap 4x.

I have some lines of code which define the layout of the left sidebar, main component area and right sidebar. In J4's Cassiopeia, both sidebars drop below the component area on a smaller screen. On mine, if both sidebars used, the right sidebar drops down first on a medium-sized screen and then on smaller screens, the they stack with the left sidebar at the top, component area next and right sidebar last.

To save cluttering up the index.php file in my J3.9.1 template files I have a file called php/template.php where the 10 lines of code are stored and the file template.php is listed in the template.xml

I can't get this to work in J4. It's just ignored. I tried adding it to joomla.asset.json and it produced an Error. Either I did it wrong, or you can't reference a php file as a dependency in a json file.

Any ideas, please?

GillianBPP
Joomla! Explorer
Joomla! Explorer
Posts: 396
Joined: Wed Oct 01, 2014 10:25 am

Re: How to get J4 to read template.php file

Post by GillianBPP » Sat Jan 12, 2019 5:00 pm

I believe I've just found my own answer:

In the PHP section of the index.php file, add this code:

Code: Select all

include_once "template.php";
So simple.


Locked

Return to “Joomla! 4 Related”