Solved

Need to dynamically insert unique code into <head>

Posted on 2013-01-04
4
426 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
  • 2
4 Comments
 
LVL 24

Accepted Solution

by:
lenamtl earned 500 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

785 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