• Priority: Medium
  • Status: Waiting on customer
  • Theme: Alysum
  • Assigned To: Fred
  • Private: No
  • Open Date: 11.12.21, 20:06
  • Opened by: pete ragaisis

Ticket #22766 - need help with module hooks for mobile version

i have made a simple module which displays some calculations and hooked it to “displayWrapperBottom” to show on one specific CMS Page, but this hook doesn’t work in mobile version of the asylum theme.

for mobile amp version i found that hook: “displayAmpContent” works, but i can not use: “if (Tools::getValue(’id_cms’) != 6)” to filter to specific page.

can anybody help with solution how to hook mymodule to show on mobile version with amp for specific page?



Fred 13 Dec 2021, 15:19

Hi, pete ragaisis.
I suggest you the following way.
1. Create a new hook in your module, for example "displayCustomCMSContent"
2. Add that hook for both desktop and AMP into the files

pete ragaisis 13 Dec 2021, 18:18

allright thanks i'll try that

Fred 13 Dec 2021, 18:20

You are welcome!

pete ragaisis 15 Dec 2021, 13:47

actually this approach doesn't change anything, if i use my module hooks or default hooks. the main quostion is how to attach to specific page id, not to all pages. in normal page mode I can use if statement in mymodule.php:

 if (Tools::getValue('id_cms') == 1)

but in amp mode this statement doesnt work... how to get page id in amp mode?

how to attach my module hook to specific amp page? do you have any other suggestions, please?

Fred 16 Dec 2021, 11:14

you can add that condition into the .tpl file of the theme.
for example for the theme it all look like this

{if $cms.id == 1}

and for AMP

{if $id_cms == 1}
pete ragaisis 16 Dec 2021, 12:25

Uhhh FINALYYYY!! i found my mistake in


my hook was in wrong place, it shoul be inside

{block name='content'}

not outside, and now everything works.

thanks for trying me to help, i hope others will find it usefull too...

this example shows how i've added mymodule hook to amp pages:

{block name='content'}
 <div class="page-cms">
  <h2 class="m15">{$cms_title}</h2>
  <div class="cms-page-content">
    {$cms nofilter}
 {block name='hook_mymodule'}
  {hook h='displayMyModule'}

and if statement to check for page id i put in mymodule.php so it works for both mobile and desktop versions:

 public function hookDisplayMyModule()
     if (Tools::getValue('id_cms') != 1) 

      ...  your content here 
      return "whatever"...);
Fred 16 Dec 2021, 12:55

Yes, that's it, I just didn't know where exactly you put the hook