?tmpl=component Doesn't Load Custom Code - Question | JoomShaper
Black Friday sale is live with flat 50% OFF. Sale ends soon! Grab your deal now!

?tmpl=component Doesn't Load Custom Code

S

Sandra97

Template 3 weeks ago

Hi,

On a SP page with a form I have some custom code in the head section of its assigned template. It works as expected on the site.

I need it to be installed as a PWA but the manifest file is not loaded and the datepicker doesn't work either because the js file is not loaded either (?tmpl=component doens't load them)

Any idea why?

Thanks in advance for your help

Sandra

0
3 Answers
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 3 weeks ago #208451

Hello Sandra97,

Sorry for the inconvenience you're experiencing.

The issue arises because when a page loads with the ?tmpl=component parameter, Joomla only renders the component's output. This intentionally excludes the template elements, including the <head> section where your manifest and JavaScript files are defined.

Consequently, your PWA manifest and datepicker scripts aren't being loaded. This behavior is by design, as ?tmpl=component is typically used for AJAX calls or embedded content where the full template isn't needed.

To resolve this, you can either include the necessary scripts directly within the component's layout or avoid using the ?tmpl=component parameter on pages that rely on your template's assets.

We appreciate your understanding.

Best regards

0
S
Sandra97
Accepted Answer
3 weeks ago #208600

Hi Atick,

Thanks for your answer.

Adding the custom code in the template component.php file works fine (but the custom code will be deleted during the next template update).

0
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 3 weeks ago #208637

Hello Sandra97,

You're absolutely correct; this method isn't update-proof. Sorry for the inconvenience. Please be sure to back up your custom code, as it might be needed again after future template updates.

Please marked the issue as solved

Best regards

0