Keyword

Using K2 fields as metadata in Head

More
12 years 1 month ago #110947 by Greg
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.
Log in  or Create an account to join the conversation.

More
12 years 1 month ago #110948 by Greg
Replied by Greg on topic Re: Using K2 fields as metadata in Head
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

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #110949 by Greg
Replied by Greg on topic Re: Using K2 fields as metadata in Head
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

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
12 years 1 month ago #110950 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Using K2 fields as metadata in Head
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.

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.

More
12 years 1 month ago #110951 by william white
Replied by william white on topic Re: Using K2 fields as metadata in Head
@Mohamed Very nice - keep them coming

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
12 years 1 month ago #110952 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Using K2 fields as metadata in Head
Thanks William

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.

More
12 years 1 month ago #110953 by Greg
Replied by Greg on topic Re: Using K2 fields as metadata in Head
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

Please Log in or Create an account to join the conversation.

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
12 years 1 month ago #110954 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Using K2 fields as metadata in Head
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.

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.

More
12 years 4 weeks ago #110955 by Greg
Replied by Greg on topic Re: Using K2 fields as metadata in Head
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.
Log in  or Create an account to join the conversation.

More
12 years 3 weeks ago #110956 by Greg
Replied by Greg on topic Re: Using K2 fields as metadata in Head
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.
Log in  or Create an account to join the conversation.

More
11 years 10 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.

More
11 years 10 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.

More
11 years 10 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

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago - 11 years 7 months 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

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 7 months ago #110961 by Krikor Boghossian
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

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 11 months ago #110962 by Joe Campbell

Please Log in or Create an account to join the conversation.