Hi again,
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.
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.
Topic Author
13 years 8 months ago #110948
To add. I think this might need to be done by a php include of the instructions K2 uses to define where the fields are in the database.
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
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
Topic Author
13 years 8 months ago #110949
Although I do appear to be having a conversation with myself. I'm getting there.
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
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
13 years 8 months ago #110950
I have developed the plugin
AutoMeta for K2
to implement this requirement and more...
With this plugin, you can use extra fields, item tags, item title, category name in meta keywords and description.
With this plugin, you can use extra fields, item tags, item title, category name in meta keywords and description.
Topic Author
13 years 8 months ago #110953
Mohamed that is awesome (I've already persuaded a client they need it)!
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
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
13 years 8 months ago #110954
Hello Greg,
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.
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.
Topic Author
13 years 7 months ago #110955
Hi Mohamed,
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.
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.
Topic Author
13 years 7 months ago #110956
If anyone can suggest why the following code isn't working that would be muchly appreciated.
Once I've got this working I can implement the rich snippets info from K2 profile, etc.
Once I've got this working I can implement the rich snippets info from K2 profile, etc.
13 years 5 months ago #110957
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.
13 years 5 months ago #110959
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
13 years 2 months ago #110960
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
13 years 2 months ago #110961
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
12 years 6 months ago #110962
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
Log in or create an account to reply.