I'm still in Joomla 4 at the moment but am upgrading to J5 in the coming month.
Here’s a recent build of
global-logic.php
- it also includes an
item.php of how I insert the code.
You can place the file in any folder you like, and you can include it in your FLEXIContent template using
modern Joomla 4/5 syntax:
Code:
require_once JPATH_SITE . '/components/com_flexicontent/templates/iamrobert/common-code/item-header-logic.php';
The old
. DS . syntax is no longer needed.
I keep my own reusable code blocks in a folder called
iamrobert under:
/components/com_flexicontent/templates/
This folder is not an actual FLEXIContent template - it’s simply a clean way to store reusable logic across multiple client projects.
If you're interested in the theory behind this setup, see here:
github.com/Lyquix/flexicontent_templates
Below is an example of how I structure my reusable blocks
Where in item.php should I insert the require_once line?
You can place it anywhere
before you use the variables or functions from
global-logic.php.
I put it near the top of
item.php, just after the opening PHP tag.
Do I need to put global-logic.php inside the same template folder?
Not necessarily — you can put it anywhere.
You only need to adjust the path in
require_once so Joomla knows where to find it.