- Posts: 14
COMMUNITY FORUM
Using K2 fields as metadata in Head
- Greg
-
Topic Author
- Offline
- New Member
Second post in 24hrs!
What I've been trying to do is use K2's fields (title, tags, image, etc.) to create extra metadata fields.
I did originally put the new tags in item.php which worked perfectly... apart from it didn't put them in the <head> tag on the page.
Now I've solved that by putting them into the head section of the template this means that I cannot call K2 fields in this way.
Log in or Create an account to join the conversation.
- Greg
-
Topic Author
- Offline
- New Member
- Posts: 14
Firstly I'm not sure where the instructions are (/www/components/com_k2/helpers possibly?)
Secondly I'm not sure how to include this info in the head tag. I'm very new to php
I think it might be something like include_once ('/K2 INSTRUCTIONS FILE.php')
Will post if I get further
G
Please Log in or Create an account to join the conversation.
- Greg
-
Topic Author
- Offline
- New Member
- Posts: 14
I've worked out the php include code but not the file that the information on the fields I'm looking for is from
<?php include $_SERVER . "/modules/mod_k2_content/helper.php" ?>
Any thoughts on what file it is? I thought helper was logical but it appears to not be.
G
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
With this plugin, you can use extra fields, item tags, item title, category name in meta keywords and description.
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
- Posts: 3722
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
Please Log in or Create an account to join the conversation.
- Greg
-
Topic Author
- Offline
- New Member
- Posts: 14
I think an auto K2 meta for Joomla 3 was very much needed.
However I'm looking also to add microdata info. In addition to what your plugin does.
I've already created a Link to Google+ in the Author info which I can hopefully call if I know where the 'instruction' file is in K2. This way the template can pull the info from K2.
Any help would be appreciated
(And +1 again to Mohamed)
Thanks
Greg
Please Log in or Create an account to join the conversation.
- Mohamed Abdelaziz
-
- Offline
- Platinum Member
- Joomla Developer
Thanks for this support :)
Can you explain what you need in more details?
I'm open to all suggestions and additions if this will help K2 community.
Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store
Please Log in or Create an account to join the conversation.
- Greg
-
Topic Author
- Offline
- New Member
- Posts: 14
Sorry for the late reply. I'm looking to use k2 author info to add microdata to pull K2 author and place it as microdata. I'm comfortable with the schema.org system
BUT I'm struggling to get to pull the relevant K2 info.
I added this to the head but it's not the correct way to pull the K2 data from the sql db.
Log in or Create an account to join the conversation.
- Greg
-
Topic Author
- Offline
- New Member
- Posts: 14
Once I've got this working I can implement the rich snippets info from K2 profile, etc.
Log in or Create an account to join the conversation.
- Reu Smith
-
- Offline
- New Member
- Posts: 4
Please Log in or Create an account to join the conversation.
- Bron Fieldwalker
-
- Offline
- New Member
- Posts: 2
Please Log in or Create an account to join the conversation.
- Bron Fieldwalker
-
- Offline
- New Member
- Posts: 2
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
- Posts: 12
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
- Posts: 15920
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
- Posts: 438
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.