THELIA Forum

Welcome to the THELIA support and discusssion forum

Offline


I have a custom backOffice template based closely on the default one, but with its own version of the includes/standard-description-form-fields.html template file. In that template file, I am calling a hook defined in a module, CustomFields, like this:

<hr>
{hook name="custom_fields.render_area"}
<hr>

On the Edit Product page, the two <hr>s are rendered but there's nothing between them. What's going on?

To get a better sense of what's happening, I went into Configuration > Hooks settings in the back office and clicked "Parse Template." This tells me that "YOUR TEMPLATE DOES NOT SUPPORT THIS HOOKS" even though the hook is right there in the template file. What does it mean for a template to "support" a hook? How can I make sure my backOffice template supports it?

Here's my config.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/  thelia-1.0.xsd">

  <hooks>
  	<hook id="custom_fields.hook" class="CustomFields\HookManager">
  		<tag name="hook.event_listener" event="custom_fields.render_area" method="onRenderArea" type="back">
  	</hook>
  </hooks>

</config>

And my HookManager:

<?php

namespace CustomFields\Hook;

use Thelia\Core\Hook\BaseHook;
use Thelia\Core\Event\Hook\HookRenderEvent;

class HookManager extends BaseHook {
	public function onRenderArea(HookRenderEvent $event) {
		$event->add('<p>hi there</p>');
	}
}

Finally, my class for the module itself:

<?php

namespace CustomFields;

use Thelia\Module\BaseModule;
use Thelia\Core\Template\TemplateDefinition;

class CustomFields extends BaseModule
{
  /** @var string */
  const DOMAIN_NAME = 'custom_fields';
  
  public function getHooks() {
    return [
      [
        'type' => TemplateDefinition::BACK_OFFICE,
        'code' => 'custom_fields.render_area',
        'title' => 'Render Custom Fields Area',
        'description' => 'Render custom fields for a specific area in the admin',
        'active' => true,
      ]
    ];
  }
}

Last edited by ctamayo (16-03-2017 22:21:04)

Online


A few questions :

1) Are you working in developmement mode (index_dev.php)
2) Did you cleared the caches ?
3) Did you try to reset you module's hook using the commande Thelia hook:clean YourModuleName ?


CQFDev | Sites, boutiques, modules, développement et intégration pour Thelia 1 et 2

Offline


Yes, I cleaned hooks and cleared the cache. Editing Contents or Products via index_dev.php still shows no hooked-in content.

Online

Offline


Now there's a thought! I found this in the log:

[ERROR 76] Opening and ending tag mismatch: tag line 14 and hook (in n/a - line 15, column 11)
[ERROR 76] Opening and ending tag mismatch: hooks line 12 and config (in n/a - line 18, column 10)

...which sure enough led me to find a slash missing in the self-closing <tag> element! So that was the problem.

HTML5 has spoiled me, gonna blame it on that ;-) Thanks!

Online