Page builder vs default item-set template

Hi there,

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.

Thanks!

1 Like

Hi tombh,

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.

Thanks boregar, I’ll give this a go. Definitely feels more maintainable.

I think I need to spend more time in the Laminas Components docs to get a better feel for the landscape.

Related question, do you have a preferred debugger for working with Omeka/Laminas? I’ve used Xdebug and Tracy a lot in the past…

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 :face_with_hand_over_mouth: so I’ll be glad to follow your investigations about that :grin:

[edit]
Concerning the debugger, I found this topic helpful: How to work on OmekaS? - #3 by fackrellj

To try Kint (Kint | Advanced PHP dumper), I installed the minimalist version (download the kint.phar file from their github repo here: kint/build/kint.phar at master · kint-php/kint · GitHub).

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
...
?>

Xdebug!
I’m using it in PhpStorm. It requires some configuration to get it to work and I’ve tried to document that here omekas-docker/README-03-PhpStorm-Xdebug.md at master · MaastrichtU-Library/omekas-docker · GitHub

I know that Xdebug works in VsCode as well and I’ve heard that the configuration is a bit more easy there.