?
Solved

Need to dynamically insert unique code into <head>

Posted on 2013-01-04
4
Medium Priority
?
441 Views
Last Modified: 2013-01-05
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.
0
Comment
Question by:sc456a
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 26

Accepted Solution

by:
lenamtl earned 2000 total points
ID: 38745886
Hi,

You can achieve this using a module, you will need to duplicate the module for each page and select the appropriate page in module settings.

Here is a list for custom code modules:
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules

EasyHeader could probably do the job:
http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules/11936
0
 
LVL 1

Author Comment

by:sc456a
ID: 38745942
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.
0
 
LVL 16

Expert Comment

by:HagayMandel
ID: 38746309
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.
0
 
LVL 1

Author Comment

by:sc456a
ID: 38747754
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question