- Posts: 4
COMMUNITY FORUM
Using K2 fields as metadata in Head
- Reu Smith
- Offline
- New Member
Less
More
11 years 4 months ago #110957
by Reu Smith
Replied by Reu Smith on topic Re: Using K2 fields as metadata in Head
I would be really interested in buying or being shown how to do this. I would love to make sure the microdata is being used on some of the newer sites I have done.
Please Log in or Create an account to join the conversation.
- Bron Fieldwalker
- Offline
- New Member
Less
More
- Posts: 2
11 years 4 months ago #110958
by Bron Fieldwalker
Replied by Bron Fieldwalker on topic Re: Using K2 fields as metadata in Head
I cant seem to post my answers
Please Log in or Create an account to join the conversation.
- Bron Fieldwalker
- Offline
- New Member
Less
More
- Posts: 2
11 years 4 months ago #110959
by Bron Fieldwalker
Replied by Bron Fieldwalker on topic Re: Using K2 fields as metadata in Head
Okay guys I have figured out a way to do it for myself without buying plugins but with some K2 Hacking
First K2 renders the page in through this
view.html.php
In directory
/components/com_k2/views/item
You can probably do this as an Override View but I didn't bother
TEMPLATE_NAME/code/COMPONENT_NAME/views/VIEW_NAME/VIEW_NAME(.FORMAT).php
The HEAD content is already rendered to the page, this can be done by Joomla or a lot of people will be using something like ACE SEF or other things which will take over the META content. There is really no point in trying to custom mod those plugins, its easier to just ask K2 to add the meta items after its loaded because this is the only time variables are really available to K2 unless you want to do a lot of work to pull data right out of the dbase or setup custom variables to pass data across Joomla.
If you scroll down you will see a section for Facebook Images
// Load Facebook meta tag -> item
$facebookImage = 'image'.$params->get('facebookImage','Small');
$document->setMetaData("image",substr(JURI::root(),0,-1).str_replace(JURI::root(true),'',$item->$facebookImage));
This doesn't seem to DO anything but at least you have an area to mod to do what you want.
What I wanted was a WORKING facebook image from K2 images
So I added this command under this section of code
$document->setMetaData('og:image', 'xYOUSITEROOTx'.$item->$facebookImage);
As $facebookImage was already defined for me.
You could then try to add more Facebook Open Graph meta content here if you like. You would have to get the variables you want to use and its not the same as if your ON the page. For example
$facebookImage = 'image'.$params->get('facebookImage','Small');
You dont need to do the title as facebook defaults to the page title anyways
First K2 renders the page in through this
view.html.php
In directory
/components/com_k2/views/item
You can probably do this as an Override View but I didn't bother
TEMPLATE_NAME/code/COMPONENT_NAME/views/VIEW_NAME/VIEW_NAME(.FORMAT).php
The HEAD content is already rendered to the page, this can be done by Joomla or a lot of people will be using something like ACE SEF or other things which will take over the META content. There is really no point in trying to custom mod those plugins, its easier to just ask K2 to add the meta items after its loaded because this is the only time variables are really available to K2 unless you want to do a lot of work to pull data right out of the dbase or setup custom variables to pass data across Joomla.
If you scroll down you will see a section for Facebook Images
// Load Facebook meta tag -> item
$facebookImage = 'image'.$params->get('facebookImage','Small');
$document->setMetaData("image",substr(JURI::root(),0,-1).str_replace(JURI::root(true),'',$item->$facebookImage));
This doesn't seem to DO anything but at least you have an area to mod to do what you want.
What I wanted was a WORKING facebook image from K2 images
So I added this command under this section of code
$document->setMetaData('og:image', 'xYOUSITEROOTx'.$item->$facebookImage);
As $facebookImage was already defined for me.
You could then try to add more Facebook Open Graph meta content here if you like. You would have to get the variables you want to use and its not the same as if your ON the page. For example
$facebookImage = 'image'.$params->get('facebookImage','Small');
You dont need to do the title as facebook defaults to the page title anyways
Please Log in or Create an account to join the conversation.
- Stonedfury
- Offline
- New Member
Less
More
- Posts: 12
11 years 1 month ago - 11 years 1 month ago #110960
by Stonedfury
Replied by Stonedfury on topic Re: Using K2 fields as metadata in Head
The file I found all the meta data is in components/com_k2/views/item/view.html.php
I am trying to remove the title, url and type.
Is there any idea on how I could make the type "article" changeable through the settings. We have recipes and type article makes google see it as an article and not "food"
I already moved the file over to my template and did an override. However the override is not changing the page. :( Any ideas on that too?
override is mysite.com/templates/mytemplate/html/com_k2/views/item/view.html.php
I am trying to remove the title, url and type.
Is there any idea on how I could make the type "article" changeable through the settings. We have recipes and type article makes google see it as an article and not "food"
I already moved the file over to my template and did an override. However the override is not changing the page. :( Any ideas on that too?
override is mysite.com/templates/mytemplate/html/com_k2/views/item/view.html.php
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
11 years 1 month ago #110961
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Re: Using K2 fields as metadata in Head
Hello,
You cannot override the view.html files. The recipe type however is not a correct og type. For your site it should always be article. You can see the valid og types here ogp.me/#types
You cannot override the view.html files. The recipe type however is not a correct og type. For your site it should always be article. You can see the valid og types here ogp.me/#types
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Joe Campbell
- Offline
- Platinum Member
Less
More
- Posts: 438
10 years 5 months ago #110962
by Joe Campbell
Replied by Joe Campbell on topic Re: Using K2 fields as metadata in Head
Here's a solution from another post (from@chilly_bang)...
getk2.org/community/English-K2-Community/167780-Add-additional-meta-tags-to-K2-items#167808
The solution requires the use of the JosTag plugin...
extensions.joomla.org/extensions/site-management/seo-a-metadata/meta-data/5139
getk2.org/community/English-K2-Community/167780-Add-additional-meta-tags-to-K2-items#167808
The solution requires the use of the JosTag plugin...
extensions.joomla.org/extensions/site-management/seo-a-metadata/meta-data/5139
Please Log in or Create an account to join the conversation.