Keyword

Plugin K2 SET MetaData

  • Antonio Jose Valdes Medina
  • Antonio Jose Valdes Medina's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 2 months ago - 10 years 2 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:
<?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.

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

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

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

  • Antonio Jose Valdes Medina
  • Antonio Jose Valdes Medina's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 2 months ago - 10 years 2 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:
$tags=& JFactory::getDocument();
                $tags->setTitle('Hello');
                $tags->setDescription('Hello 2');
The plugin does not work on a plugin, but in item.php does work the same code.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 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.

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

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

  • Antonio Jose Valdes Medina
  • Antonio Jose Valdes Medina's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 2 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.

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


Powered by Kunena Forum