Native function to add code to Head
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
-
- Joomla! Enthusiast
- Posts: 102
- Joined: Wed Aug 02, 2006 1:37 am
Native function to add code to Head
Hi,
Can anyone tell me the native Joomla function to add code to the head of the page? I need it to add custom open graph tags. Thanks advance.
Can anyone tell me the native Joomla function to add code to the head of the page? I need it to add custom open graph tags. Thanks advance.
- jbuzzeo
- Joomla! Intern
- Posts: 58
- Joined: Tue Jul 29, 2014 1:25 am
- Location: Wilmington - South Eastern North Carolina - USA
- Contact:
Re: Native function to add code to Head
there are several extensions that claim to handle this in the JED -> http://extensions.joomla.org/
I don't actually have experience with any of them, but it's a place to start
I don't actually have experience with any of them, but it's a place to start
Jason Buzzeo - Follow me on Google+
http://www.ParadigmCustomSolutions.com - Custom web development for organizations big and small
^- Specializing in Joomla 2.5 & 3.0
http://www.ParadigmCustomSolutions.com - Custom web development for organizations big and small
^- Specializing in Joomla 2.5 & 3.0
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Native function to add code to Head
There is no native function for OG tags though there is for http-equiv and name (http://docs.joomla.org/JDocument/setMetaData)
Use a plugin from the list at http://extensions.joomla.org/extensions ... open-graph or add these lines to the head php tag of index.php
Use a plugin from the list at http://extensions.joomla.org/extensions ... open-graph or add these lines to the head php tag of index.php
Code: Select all
$app = JFactory::getApplication();
$document = JFactory::getDocument();
$og = '<meta property="og:title" content="'.$document->title.'" />' ."\n";
$og .= '<meta property="og:type" content="Magazine" />' ."\n";
$og .= '<meta property="og:url" content="'.rtrim(JURI::base(), '/').$_SERVER["REQUEST_URI"].'" />' ."\n";
$og .= '<meta property="og:image" content="'.JURI::base().'images/ogimages/default.png" />' ."\n";
$og .= '<meta property="og:site_name" content="'.$app->getCfg('sitename').'" />' ."\n";
$og .= '<meta property="fb:admins" content="65745237346832" />' ."\n";
$document->addCustomTag($og);
Last edited by jackrabbit on Thu Jul 31, 2014 9:29 pm, edited 1 time in total.
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely
-
- Joomla! Enthusiast
- Posts: 102
- Joined: Wed Aug 02, 2006 1:37 am
Re: Native function to add code to Head
Actually what I need is a function to add code to the head of the page. I know how to add og tags, but I want a function that will inject a custom code (where I have all the og tags) to the head of that page.
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Native function to add code to Head
$document->addCustomTag($og); will add the code to the head. Other head functions are
addStyleSheet()
addStyleDeclaration()
addScript()
addScriptDeclaration()
setMetaData()
and many more. Your original question specifically said you want to add custom OG tags and that is what the code I laid out will allow. Otherwise you will need to layout a precise and sensible explanation of your ultimate goal.
addStyleSheet()
addStyleDeclaration()
addScript()
addScriptDeclaration()
setMetaData()
and many more. Your original question specifically said you want to add custom OG tags and that is what the code I laid out will allow. Otherwise you will need to layout a precise and sensible explanation of your ultimate goal.
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely
-
- Joomla! Enthusiast
- Posts: 102
- Joined: Wed Aug 02, 2006 1:37 am
Re: Native function to add code to Head
I apologize for not being more precise. I'll try to explain it in detail. Are you familiar with the jReviews extension?
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Native function to add code to Head
I know of it but have never used it.
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely
-
- Joomla! Enthusiast
- Posts: 102
- Joined: Wed Aug 02, 2006 1:37 am
Re: Native function to add code to Head
I'm using it for music. It allows you to add custom fields to each listing (which works as a joomla article) and one of those fields I insert several OG tags together.
So I need a function which will tell jReviews to send the data on that custom field to the head of the page, to include those OG tags.
So I need a function which will tell jReviews to send the data on that custom field to the head of the page, to include those OG tags.
- jackrabbit
- Joomla! Ace
- Posts: 1473
- Joined: Thu May 21, 2009 3:12 am
- Location: Florida
- Contact:
Re: Native function to add code to Head
Well now you are outside the Joomla core. It is neither general or new to joomla. This should have been posted in the forum relative to extensions http://forum.joomla.org/viewforum.php?f=620
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely