- Posts: 21
COMMUNITY FORUM
Plugin K2 SET MetaData
- Antonio Jose Valdes Medina
-
Topic Author
- Offline
- Junior Member
Less
More
10 years 9 months ago - 10 years 9 months ago #130698
by Antonio Jose Valdes Medina
Plugin K2 SET MetaData was created by Antonio Jose Valdes Medina
Hello there!
I'm building a plugin where K2 add metadata from the form that works with K2 Tabs.
The xml is correct, display the fields on admin K2 item, but not how to enter my data and meta data on my php code plugin:
Any idea?
Thank you!
I'm building a plugin where K2 add metadata from the form that works with K2 Tabs.
The xml is correct, display the fields on admin K2 item, but not how to enter my data and meta data on my php code plugin:
<?php
// no direct access
defined('_JEXEC') or die ;
// Load the K2 Plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.'/components/com_k2/lib/k2plugin.php');
// Initiate class to hold plugin events
class plgK2k2seo extends K2Plugin
{
// Some params
var $pluginName = 'k2seo';
var $pluginNameHumanReadable = 'SEO Tags';
function plgK2k2seo(&$subject, $params)
{
parent::__construct($subject, $params);
}
function onK2PrepareContent(&$item, &$params, $limitstart)
{
$tags=& JFactory::getDocument();
$tags->setTitle('Hello');
$tags->setDescription('Hello 2');
//This is a test
}
}
Any idea?
Thank you!
Please Log in or Create an account to join the conversation.
- Lefteris
-
- Offline
- Platinum Member
Less
More
- Posts: 8743
10 years 9 months ago #130699
by Lefteris
Replied by Lefteris on topic Re: Plugin K2 SET MetaData
Hi. You might want to take a look at the example plugin at github.com/joomlaworks/example-k2-plugin/ to see how it reads the data entered by the user.
Please Log in or Create an account to join the conversation.
- Antonio Jose Valdes Medina
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
10 years 9 months ago - 10 years 9 months ago #130700
by Antonio Jose Valdes Medina
Replied by Antonio Jose Valdes Medina on topic Re: Plugin K2 SET MetaData
Yes, I followed all the steps.
And to print user data in Html page and text, no problem.
The problem I have using the classes to change the metatag:The plugin does not work on a plugin, but in item.php does work the same code.
And to print user data in Html page and text, no problem.
The problem I have using the classes to change the metatag:
$tags=& JFactory::getDocument();
$tags->setTitle('Hello');
$tags->setDescription('Hello 2');
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
10 years 9 months ago #130701
by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Plugin K2 SET MetaData
It will not work on a plugin beacuse you have not read the data by the user.
You need to follow the codebase of the demo plugin.
You need to follow the codebase of the demo plugin.
Please Log in or Create an account to join the conversation.
- Antonio Jose Valdes Medina
-
Topic Author
- Offline
- Junior Member
Less
More
- Posts: 21
10 years 9 months ago #130702
by Antonio Jose Valdes Medina
Replied by Antonio Jose Valdes Medina on topic Re: Plugin K2 SET MetaData
Yes, but how do I change the meta data from a K2 plugin?
In the demo of plugin does not explain.
In the demo of plugin does not explain.
Please Log in or Create an account to join the conversation.