Solved

Need to dynamically insert unique code into <head>

Posted on 2013-01-04
4
423 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now