I’m working on a custom theme which requires lots of display-only content which doesn’t fit into DC or another vocab. Eg colour palette and teaser text for each item set.
I’m working on the item set page at the moment (which as I understand uses the item/browse.phtml template). I’m finding that my current approach - overriding the various template parts - is starting to feel very hacky. For example, in the resource-values.phtml, I’m having to add lots of conditionals to show and hide labels based on what property we’re showing, and where the partial is being rendered.
Is this approach right, or should I be using custom pages with a block builder or something? I come from a Wordpress/Craft CMS background where templating is often a lot more open-ended so keen to get a sense of how this compares.
Why not write a set of “sub-partial” templates, one for each specific case of your conditional, and one for the generic case?
For example, I have a code of this type in one of my templates:
switch($yourCaseIdentifier) {
case 'firstcase':
// set some variables
$parameters = [...];
break;
case 'secondcase':
// set some variables
$parameters = [...];
break;
default:
// set some variables
$parameters = [...];
}
echo $this->partial('common/block-layout/' . $yourCaseIdentifier, $parameters);
Depending on the condition, a different partial will be called.
Hi tombh, I got stuck so many times in the Laminas docs that I may not be the best referent on this subject. As for the debugger, I still haven’t chosen one yet so I’ll be glad to follow your investigations about that
It works well when I use it this way in any template:
<?php
include 'kint.phar';
...
Kint::$depth_limit = 3; // by default, the limit is set to 0 (no limit), this can lead to memory exceptions depending on the memory limit of your server
d($something); // outputs the debug info about $something
...
?>