3

We were Googling to find an extension that maybe existed that adds code (or not_ based on certain routes.

Based on the router it either adds some code in before_body_end or header. Much like Config->Miscellaneous Scripts only with a little more granularity.

We have come across some solutions to add custom code to a router via extension.

But I was wondering if a more robust solution already exists. Where one would select the route from a dropdown list (of routes) and then enter the code or external JS one would want to add. And if not, how would we begin the task of setting this up.

Almost sounds like a great idea ;)

Links

Adding external JS

Magento routes

1 Answer 1

1

You could use an "extension" called Mage_Widget1, if the UI is not too complicated for your needs.

As widget type, I choose "static block" and create a static block that contains the script(s) to be added. The block can be selected in the "Widget Options" tab.

Example: Widget Options

Using "Display On", I select a route (can also be a specific CMS page or specific product).

The "Block Reference" references the parent block: Page Bottom is the label for before_body_end, Page Top the label for after_body_start.

Example: Frontend Properties


1) This is a core module, just open "CMS > Widget Instances" in the admin panel

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.