backdrop-contrib / entity_plus

This module wraps in a variety of additional entity-related functionality from various sources. Partial port of D7 Entity API.
https://backdropcms.org/project/entity_plus
GNU General Public License v2.0
3 stars 11 forks source link

Consolidate css classes variables passed to entity_plus templates #152

Closed argiepiano closed 1 year ago

argiepiano commented 1 year ago

When Backdrop dropped the "theme process" layer, it made changes on how variables containing css classes are passed to templates. In D7, the process layer flattened $classes_array into a string $classes before passing it to the template. With this change, Backdrop charged the template with flattening the array, AND also changed the names of the variables. In Backdrop, $classes is now an array of css classes that must be flattened by the template before outputting.$classes_array was completely abandoned.

Entity Plus did not adapt to this change - perhaps for backward compatibility. So, now we are in a situation when there are TWO css class variables available to templates, after running template_preprocess_entity_plus(). We have $classes, which contain an array of css classes built by core's template_preprocess(), and we have $classes_array, built during template_preprocess_entity_plus(). Unlike $classes which (for entities that use EntityPlusController) typically contains one css class, entity-plus, the variable provided by E+, $classes_array, contains (in addition) css classes derived from the actual name of the custom entity.

On the other hand, the template provided by E+ uses $classes to produce the output.

So we are missing out on the richer array of css classes provided in $classes_array, which is never used by entity_plus.tpl.php.

Proposed solution:

At this point it would be unwise removing $classes_array, provided by E+ preprocessor, as custom modules that use EntityPlusController may depend on it. I suggest that we actually keep both, $classes and $classes_array, but merge them during the E+ preprocessing so that they contain identical css classes.

We also need to fix the docblock for entity_plus.tpl.php to correctly say that $classes is an array, not a string (which has been the case since the removal of the theme process layer in Backdrop).

argiepiano commented 1 year ago

PR #154 ready for review.

laryn commented 1 year ago

LGTM!