Link to home
Start Free TrialLog in
Avatar of sc456a
sc456a

asked on

Need to dynamically insert unique code into <head>

I have some Google Publisher ads that I need to setup on a site which require specific code to be inserted into the <head> area of each page, but they need to be unique. In other words, the home page will have certain code in the <head> to correspond with the ads on that page, and the Contact Us page will have different ads and different code in <head>.

I can't seem to find any way to do this dynamically in Joomla 2.5.7. I'm currently using Flexi Custom Code modules for the ad code and that works fine but there is no way to dynamically insert the correct code into the <head> based on the page the visitor is on. I've searched the forums and for extensions - no dice. AdSense extensions won't work because they only inject the ad code - not the <head> code.
ASKER CERTIFIED SOLUTION
Avatar of lenamtl
lenamtl
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sc456a
sc456a

ASKER

I've tried several. Custom HTML Advanced doesn't work because it just injects the code as a CSS style reference. EasyHeader doesn't allow you to inject code based on an article or module; just one interface that injects the code site-wide.
I'm not a Joomla man but it seems that the direction to accomplish this should be the template page:
In other words, a script that rebuilds the head section according to the current page id/title, prior to the actual page rendering.
Avatar of sc456a

ASKER

I had to try a bunch to find one that would do it: Robert Went's Mod Custom Plus will do the trick. Here is the link:

http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/17842