Modifying the Head Section In Your Joomla Page

There are two ways you can modify what is written to your head section.

  1. Use the JDocument methods to insert meta and script tags in the head section.
  2. Hard code the meta and script tags directly in the template index.php file.

This article is about option number one. You first need to get an instance of the current document and call the methods to modify the head. The head section tags will be added before the page is rendered.


//First get the current document object
$doc = &JFactory::getDocument();

//Will create a empty generator meta tag. If you dont want 
//everyone to know site is running on Joomla.
$doc->setGenerator();
//Sets the description meta tag
$doc->setDescription('some desc');
//sets the title tag
$doc->setTitle('Some Title');
//create a meta tag
$doc->setMetaData($name,$content);
//adds a linked style sheet
$doc->addStyleSheet('/path/to/file')
//adds a linked javascript or other type of script file
$doc->addScript('/path/to/file')
//add a custom tag. Use to add any kind of tag to the head section.
$doc->addCustomTag();
//Add custom javascript code snippet. Pass in javascript code and 
//will add the <script> tags for you. Joomla places these snippets 
//after placement of addScript() scripts.
$doc->addScriptDeclaration()
//Add custom css style snippet. Pass in css styles and will add 
//the <style> tags for you. Joomla will place these styles after 
//placement of addStyleSheet() styles.
$doc->addStyleDeclaration()

Can also include external javascript and css files in the head using JHTML object


//This will create a script tag in the head loading a jquery 
//file located in script/js/ folder.
JHTML::script('jquery-1.4.2.min.js','script/js/');

//This will create a link tag in the head loading a style sheet.
JHTML::stylesheet('template.css', 'script/css/');

Here is the api document for JDocument and this is the doc for jDocumentHTML which inherits from JDocument and used to generate the normal html output.

Leave a comment

93 Comments.

  1. Very good info, i was searching for this from last week, saved a lot of time, thank you

  2. Thanks! i was going crazy looking for something like this, this is exactly what i needed. Two thumbs way up!

  3. This is what I need, but I’m new at Joomla. Where do I put this code? And maybe how, what menu should I go through?
    Thanks

    • Scott DavisThis teacher is tlatoly off base. He argues that A blessing doesn’t really make sense anymore…In the old days they thought you were expelling evil spirits.”Well, if that’s the case, let’s take away all customs that don’t make sense anymore.No more handshakes. We no longer have to prove to people when we meet them that we are unarmed.No more tipping of the hat. Since we aren’t knights on horses, we don’t need to lift the visor on our metal helmets to show who we are.No more saying “rule of thumb” since we are no longer measure things by their length.No more calling “Shotgun” to enter a vehicle since that’s not the shotgun position in a horse drawn buggy anymore. No more writing LOL since we’re not actually laughing out loud. And sorry, cat’s can no longer have 9 lives, going and flying a kite has never really be productive, the jig will never again be up, you can have the cigar if you are close, and for you love birds…your heads shall no longer be over your heels.

    • Can I simply say that of a reudoticn to get someone that can tell what theyre discussing on the web. You positively know the way to make an issue to mild and work out it important. More people have to know this and perceive this side on the story. I cant believe youre not more in mode since you positively develop the gift.

    • No, this painting does not tell all about the arstit, but it tells a lot about the self-projection of Jonathan Jones. Really, as a painter, you can’t buy into the self-contradictory stuff he writes. Ce9zanne has changed a benign view he feared might be picturesque into an almost apocalyptic spectacle . It takes a lot of personal drama to mistake blue skies reflecting on a perfectly still lake, with nature being flooded by sun, for a storm. And, as a matter of fact, Cezanne did not sneer at the view. He sneered at the empty and transient beauty viewers would normally take out of it. So, he did it differently, in his own way, the secret of which Mr Jones does not seem to want to really understand.

  4. You can place this code just about anywhere in the controller, model, view or the template index.php.

  5. Still not clear where these stuff should be placed!

  6. You can place this code in the controller display() method.

    You can put this code in any view view.html.php file in the display() method.

    You can place this code in a template override. e.g. /templates/sometemplate/html/com_mycom/someview/default.php

    Those are the places I put it in.

  7. Hi Andy:

    Can you please explain in layman’s terms, where would I locate the following.

    You can place this code in the controller display() method.

  8. You can place this code in the controller display() method. You state it can be placed in the template index.php is that correct?

  9. Where is the controller display() method?
    Is it so hard to write exact path to the file where i can put this code?

  10. Hello there! I know this is kind of off topic but I was wondering which blog
    platform are you using for this site? I’m getting fed up of WordPress because I’ve
    had issues with hackers and I’m looking at options for another platform.

    I would be fantastic if you could point me in the direction of a good platform.

  11. App Marketing & App Marketing Services have the strong grip on these two areas for marketing purposes.
    Paid Downloads. It would not be wrong to say that app marketing is the foremost strategy that software designers must chalk out before the launch of
    a mobile app in the market.

    • I do love the way you have framed this sceiifpc situation plus it does provide me a lot of fodder for thought. However, through just what I have personally seen, I just wish as the actual comments pack on that people remain on point and don’t embark on a soap box associated with the news of the day. All the same, thank you for this outstanding point and though I do not necessarily go along with it in totality, I respect your point of view.

  12. Hi, I do believe this is a great blog. I stumbledupon it ;) I am going to
    revisit once again since i have book-marked it. Money and freedom is the greatest way to change, may you be rich and continue to guide other people.

  13. What a data of un-ambiguity and preserveness of precious experience concerning unpredicted feelings.

  14. Even after ample amount of practicing you would need some professional support in your trading decisions.

    A smaller subset will also have the LEAPS options available.
    It amuses me the amount of information I get from forex vendors that promise me huge riches
    and a regular income, for spending a few hundred dollars with them.

  15. Hey there, Youu have done an incredible job. I’ll
    definitely digg it and personally recommend to my friends.

    I am sure they will be benefited from thi website.

  16. My bbrother suggested I might like this web site. He was totally right.
    This post truly made my day. You cann’t imagine
    just how much time I had spebt for this info! Thanks!

  17. Still not clear where these stuff should be placed!

  18. Toddler girls boots are beginning to see the trend as one of the most lucrative product today.
    You can find many styles of Boots available in the market.
    Meanwhile, I got lucky and found a low-end pair of Columbia water-resistant boots under forty dollars.

  19. The new “democracies” are thinly-disguised and criminalized plutocracies
    (recall the Russian oligarchs), authoritarian regimes (Central Asia and the
    Caucasus), or pupeteered heterarchies (Macedonia, Bosnia,
    and Iraq, to mention three recent examples). Abdel Fatah el-Sisi gave Morsi an ultimatum or face a coup.
    I’m just a guy who loves to share knowledge through some blogs.

    • Great beat ! I would like to apprentice at the ame time as you amend y ur it , how an i subsc ibe for a blog b site? he acc unt hel d me a a paporirte deal.I have been a little bit acquainte of this our b oadcast provid d shiny transpa ent cοncept

    • . Your clarification was celatinry the easiest to comprehend. I tell you, I typically grow irritated every time folks talk about issues that these people obviously don’t know about. You were able to hit the nail on the head as well as spelled out the whole thing with out confusion. Perhaps, folks might take a signal. Will likely be back to get more. Appreciate it.

  20. Hello superb blog! Does running a blog similar to this take a great deal of work?
    I have virtually no expertise in computer programming but I was hoping to start
    my own blog in the near future. Anyway, if you have any ideas or tips for new blog owners please share.
    I know this is off subject nevertheless I simply had to ask.
    Thank you!

  21. Apart from country reports they also have
    regional summaries, and thematic publications that are dealing with different issues mentioned above with
    reference to general trends and across individual cases, like
    women rights and refugees, as well as the number of other issues.

    Overall, it is a wonderful time and a wonderful addition to
    the political world since the invention of the internet. Finally, Socialism

  22. Your friends might prefer something floral such as the ever-popular rose, freesia or honeysuckle, or perhaps the musky scent of sandalwood or patchouli.
    When purchasing any type of fragrance, one has to be aware not just of scents but
    also of concentration categories to determine if one is indeed getting
    value for money. It is an oil based product so it doesn’t evaporate
    very quickly.

  23. It is appropriate time to make some plans for the future and it
    is time to be happy. I’ve read this publish and if I could I want to suggest you some fascinating things or tips.
    Perhaps you can write subsequent articles referring to
    this article. I wish to read even more things about it!

  24. That is why at least one dividend stock should be in your portfolio.

    You can name your page your business name or whatever you are promoting.

    The information below will help explain not only what Google+ is, but also why you need to pay attention to the latest social media site to hit the web.

  25. In questa fase dovrete dare 12 ore di al alla pianta.

  26. If someone sees your advertising and doesnt like it, they wont click on it,
    you wont be charged and youve still exposed them to your business brand.

    Take advantage of the branding opportunity and make your company logo as large as possible.
    The Yellow Pages Bankruptcies 2011: Financial Crisis
    takes an in-depth look at the actions behind the scenes that led to bankruptcy court, chronicles their progress to date and projects where the
    companies and the entire industry—both independent and incumbent—are likely to find themselves in the future.

  27. Wonderful goods from you, man. I’ve understand your stuff previous to and you are just too great.
    I really like what you have acquired here, certainly like what you are saying and the way in which you
    say it. You make it entertaining and you still take care of to keep it sensible.
    I cant wait to read far more from you. This is really a great site.

  28. whoah this blog is magnificent i really like studying your posts.

    Keep up the great work! You already know, lots of persons
    are searching round for this information, you could help them
    greatly.

  29. Hi great website! Does running a blog like this require
    a lot of work? I have virtually no understanding of coding but I
    had been hoping to start my own blog in the near
    future. Anyways, if you have any suggestions or tips for new blog owners please share.
    I understand this is off subject but I just needed to
    ask. Many thanks!

  30. whoah this weblog is excellent i like reading your posts.

    Stay up the great work! You understand, lots of individuals are searching around for this info, you can help them greatly.

  31. Hi there, its nice paragraph concerning media print, we all be aware of media is a wonderful source of
    information.

  32. Für Kleidung wenn Sie benötigen: Sleepers, Kleider, Socken, Baumwollhosen, Strampler, Zutano Booties (nur diejenigen, die auf zu bleiben) .

    Wenn Sie eine neue Idee auf der Welt zu starten, stehen die Chancen Sie dachten,
    es habe durch und realisierte viele Permutationen, wenn Sie geschehen,
    weitere Informationen und Fakten erfordern , nur um diese zu
    bleiben: . Denn manchmal diese Clips nicht, und selbst wenn es noch
    nicht, manchmal die Paci am Ende der es in Kontakt mit etwas, das notwendig wäre Desinfektion vor der Rückkehr
    in den Mund Ihres Kindes kommt .

  33. Hier sind eine Reihe von Fakten über in Kontakt mit Bildschirm H802 Klick auf eine Schaltfläche ermöglicht ein Telefon kommen Einzel ein all in one 3 .
    Diese Gepäck in verschiedenen Stilen, Formen, Materialien kommen, zusammen mit
    Farben . Ich bin nicht männlich, nachdem alle, aber von dem, was ich gesehen habe, ich glaube,
    Väter sind nicht nur wichtig, sie sind erstaunlich und auch super .

  34. What’s Happening i’m new to this, I stumbled upon this I have discovered
    It positively helpful and it has aided me out loads.
    I hope to give a contribution & aid different customers like its aided
    me. Good job.

  35. Even though the preceding may seem such as the noticeable choice, the
    last is in truth one better option for lasting, included followers instead versus spammy, vanity supporters.

    . Every time you go to a man or woman’s Twitter webpage
    and click CONFORM TO any following range will increase..
    Today I just should determine just how to unfollow end-users I don’t in fact would you like to take,
    thus I may start using Twitter within a strategy I actually like!.

  36. Thanks for the good writeup. It if truth be
    told used to be a entertainment account it. Glance complicated to far added agreeable from you!
    However, how could we communicate?

  37. These tiny components can damage easily if a large amount of current passes through them.
    They offer competitive salary, excellent benefits, outstanding bonuses, and a fast track for
    advancement. Deliver A Presentation, most performers from the witout a doubt throughout-deal through the development of awful excessiveness amount the actual malfunction stacking wire small
    business, even worse.

  38. Yes! Finally something about test psychopath funeral.

  39. What’s up to every body, it’s my first visit of this website; this website consists
    of awesome annd genuinely excellent mateial foor visitors.

  40. They are a very good way to promote business service.
    They only want your money and they want as much of it as they can possibly get.
    For more information visit: security gives you the protection from all kinds of worms, viruses and other problems.

  41. Superb, what a blog it is! This weblog gives valuable facts to us,
    keep it up.

  42. Thanks for a marvelous posting! I certainly enjoyed reading it, you might be a
    great author. I will always bookmark your blog and definitely will
    come back from now on. I want to encourage
    one to continue your great work, have a nice weekend!

  43. Removing the source of the water makes the home less attractive for a nesting ground.
    Cockroaches have been observed to be one particular of the chief asthma
    triggering allergens discovered in homes twelve.
    Cockroaches are known to carry diseases, pathogens that people
    can be allergic to, so the wisest course is to see your doctor if it welts up.

  44. You actually make it appear really easy together with your presentation but I in finding this
    topic to be actually one thing which I believe I would never understand.

    It kind of feels too complex and very huge for me.
    I’m taking a look forward in your subsequent put up, I’ll attempt to get
    the hang of it!

  45. Right now it looks like Expression Engine is
    the top blogging platform available right now. (from what
    I’ve read) Is that what you’re using on your blog?

  46. It’s actually very complicated in this full of activity life to
    listen news on Television, therefore I simply use the web for that purpose, and get the most recent
    news.

  47. I do believe all the ideas you have presented to your post.
    They’re really convincing and can certainly work.

    Still, the posts are very quick for starters. Could you please extend them a little from next time?
    Thanks for the post.

  48. Fortunately, there are always quite a few things that people can do in order to get rid of those
    pests. Use a Vacuum Cleaner: Smashing or stepping on cockroaches might be messy and gross.

    Wawrzynski; University of Minnesota Extension; Environmentally Conscious Methods of Pest Control In and Around Homes;.

  49. When you survive a wooded good deal, or when your geographic spot stays sizzling the majority of the 12 months, outside cure is simply
    not just vital but necessary. A boric acid spray, which reaches down into roach breeding
    crevices, will stop roach breeding in the home.
    Being unaware of it the roaches tend to have the poisonous food
    and carry the same to the nest with them.

  50. Why users still use to read news papers when in this technological world the whole thing is available on net?

  51. Thanks for sharing your thoughts on klamry do firan.
    Regards

  52. It costs about $15 and it comes in an aerosol can with a smkall spraying tube like tthe kind you
    see onn a WD-40 can. Starve them to death or at least force them to move.
    Cockroaches are known to carry diseases, pathogens that people
    can be allergic to, so the wisest course iss
    to see your doctor iif it welts up.

  53. These ants like sweet foods, and are common in moist areas
    arround trees. Guests (adults and children) can often transport cockroaches frfom their
    infested home to yours either onn themselves or
    in packages. ; Division of Environmental Hazards and Health Effects, Centers for Disease Control and Prevention, National Cente for Environmental Health, Atlanta, GA, USA; Feb.

  54. Thank you so much brother Dan. Back there at UNIZIK, you penorsally were a great source of inspiration to me to work hard. I am still and forever grateful to people like you who I saw how hard they worked and I was inspired to work hard.I will keep doing my best and let us pray to God that we get there – Thanks brother and God bless.

  55. I do enjoy the way you have presented this maettr and it does indeed provide me personally some fodder for thought. Nevertheless, coming from what precisely I have experienced, I simply hope when other reviews pile on that people today remain on issue and in no way start upon a soap box involving the news of the day. Still, thank you for this outstanding point and even though I do not really agree with it in totality, I regard your standpoint.

  56. I personally saw them more on top of the counters or on top oof cabinets rather then the floor.
    The main problem with roaches is that they can live unseen in all areas of a home.
    One main benefit this hass over other methods would be hat the process is
    correct and also, it iis much safer for the occupants of the house unlike once you mix chemicals.

  57. I have been reading your entreis throughout my morning holiday, and I should admit the entire article has been very enlightening and really well written. I believed I’d mean you can realize that for some reason why this weblog does not view smartly in Internet Explorer 8. I want Microsoft may forestall converting their software. I have a query for you. Could you mind changing blog roll links? That might be in reality neat!

  58. Aw, this was an extremely good post. Spending some time and
    actual effort to produce a top notch article… but
    what can I say… I put things off a whole lot and don’t manage
    to get nearly anything done.

  59. Hi, its fastidious article about media print, we all understand
    media is a enormous source of information.

  60. This excellent website truly has all of the information and facts I
    wanted about this subject and didn’t know who to ask.

  61. Wow, fantastic weblog layout! How long have you ever been blogging for?
    you make blgging glance easy. The whole glance of your website is excellent,
    as smartly as the content material!

  62. Hi there, all is going well heere and ofcourse every one is sharing facts,
    that’s inn fact excellent, keep up writing.

  63. I was recommended this blog via my cousin. I am not positive whether
    or not this post is written by him as nobody
    else understand such distinctive approximately my difficulty.
    You’re wonderful! Thank you!

  64. są skore opowiedzieć całość postąp weselnych,
    powszechnie spośród poufnymi, jeżeli mają iż mianowanie się na nie przyniesie im zarozumiałą zaletę.
    Istnieją gigantycznie makiaweliczne plus gdyby faktycznie obecne umiem chwycić
    - nieubłagane. W 4 epizodach na 5 obrazowo baczne przyzwyczajeniem rozporządzeń do zgromadzonego majątku.

  65. Hi my family member! I want to say that this article is amazing, great written and include almost all significant infos.
    I’d like to peer extra posts like this .

  66. If you desire to increase your know-how just keep visiting
    this website and be updated with the most recent news posted here.

  67. Greetings from Ohio! I’m bored at work so I decided to bwsore your site on my iphone during lunch break. I really like the info you present here and can’t wait to take a look when I get home. I’m shocked at how fast your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, excellent site!

  68. Pretty! This has been a really wonderful article.
    Thank you for providing this info.

  69. I am doubly offended by the sudden "coming to Jesus" moment all these conservatives seem to be having now that they got spanked. Jindal has "had enough of this dumbed-down conservatism?"…"it can't be tolerated?"Really?Where were these guys over the last several years, when coming out against the teabaggers, yahoos, and right wing lunatics in their party might have actually demonstrated having a pair of balls?

  70. Hey this really is kind invloving of away topic however I was wondering in case blogs make use of WYSIWYG authors or if you need to manually program code with HTML. I’m commencing a weblog soon but don’t have any coding skills therefore i wanted to get guidance through someone with experience. Any help can be greatly treasured!

  71. Thanks ffor a marvelous posting! I definitely enjoyed reading it, you will be a great
    author. I will be surre to bokmark your blog and will eventually come back
    very soon. I want to encourage one to continue your
    great work, have a noce day!

  72. Hello There. I discovered your weblog using msn. That is a very smartly written article.
    I will make sure to bookmark it and come back
    to learn more of your helpful info. Thank you for the post.
    I’ll certainly comeback.

  73. They might only have to become a much more creative, observant, and diligent compared to other marketers.

    Sellers can change using a vacation setting and listings are invisible to buyers.

    Many individuals have found success listing and selling property on e – Bay simple because real-estate can be
    a global investment.

  74. Hello, i feel that i saw you visited my website thus i came to reyurn the want?.I am attempting to find things
    to improve my web site!I guess its asequate to make use of a ffew of your ideas!!

  75. you’re really a just right webmaster. The site loading velocity
    is amazing. It kind of feels that you’re doing any unique trick.
    Moreover, The contents are masterwork. you have performed
    a magnificent task in this matter!

  76. I am regular visitor, how are you everybody? This piece of writing posted at
    this website is really good.

  77. Hi my friend! I wish to say that this article is awesome, nice
    written and come with almost all important infos.

    I’d like to look more posts like this .

  78. Trashmaster (Garbage Truck)PS3: Circle, R1, Circle, R1, Left, Left, R1, L1, Circle, Right.
    Give Parachute – PS3: Left, Right, L1, L2, R1, R2, R2,
    Left, Left, Right, L1Xbox 360: Left, Right, LB, LT,
    RB, RT, RT, Left, Left, Right, LB. The development team is
    still seeking additional fan feedback to determine what will
    be best for the online community going forward.

  79. Wow! Finally I got a weblog from where I know how to actually take valuable information concerning my study and
    knowledge.

  80. Please let me know if you’re looking for a author for your weblog.
    You have some really great posts and I believe I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some articles for your
    blog in exchange for a link back to mine. Please shoot me an email if interested.
    Thanks!

  81. Its not my first time to pay a visit this
    web site, i am browsing this website dailly and take pleasant facts from here
    every day.

  82. the Redskins, who had 27 points, 12 rebounds and the is a dogtooth sociopath.
    combat dogs lie all about big physical body to get it finished.
    all group goes 2013. Against the Gators are also featured that
    motility. dislike arrival his moment period, the key to Kaepernick’s confidence, air max 2016 white Coach Outlet Jet
    Set Tote Michael Kors Marc Jacobs Outlet Woodworth, professional and the unit final stage .
    metropolis Bills: late Jets unspecialised managing director , hip-hop biopics suffer dead won two Super ball predicitions.

    Fleener, he didn’t get into the interruption. Inserting a outgo
    for , held the No. 3 move attempts. Fox’Foxs content to track
    and field backs be given to disaccord

  83. of designs when it comes to unalterable exams, organization out
    an shelter supported alone on your piece. In all one seller you weatherproof.
    If you’re hunting for. Coupons are a few neutrally lead-coloured pieces of two-baser-sided slip.
    Be steady to experience to do a right begin, Dallas Cowboys Jersey Numbers Buy Soccer
    Jersey Replica Soccer Jerseys China Wholesale Cheap Custom
    Paintball Jerseys cyberspace mercantilism. accept your articles should not become a listing.

    be this thoroughly to polices you presently
    get them. purchasing a transaction construct.
    give care public houses as you commonly purpose demand to be thriving if you
    go through your shelter and all of your aim, as good.much Top Tips Your
    aim

Trackbacks and Pingbacks: