Kunena 6.2.6 released

The Kunena team has announce the arrival of Kunena 6.2.6 [K 6.2.6] which is now available for download as a native Joomla extension for J! 4.4.x/5.0.x. This version addresses most of the issues that were discovered in K 6.1 / K 6.2 and issues discovered during the last development stages of K 6.2

This category contains miscellaneous, uncategorised user contributions, (templates, modules, plugins and hacks) relating to older versions of Kunena that are no longer supported.

The topics in this category are for historical interest only. Owing to the structural changes that occurred in K 2.0, many of the ideas in these topics will not work with later versions and, for that reason, the topics are locked.

Question Manually trigger Topic Creation

More
11 years 10 months ago - 11 years 4 months ago #1 by Shynx
already searched for quite a while, but im coming up empty. here is my scenario:

i have a component that creates an article by manually inserting it into joomlas content table.
i want kunenadiscuss to create its starting post (which is normally created upon first visit) directly after the components has inserted the article.

i toyed around with triggering the events kunenadiscuss utilizes, but up to date information is hard to come by. any help would be greatly appreciated

im running j2.5 and kunena 1.7

here are my feeble attempts at triggering kunenadiscuss related events:

First Attempt:
Code:
JPluginHelper::importPlugin('content'); $dispatcher =& JDispatcher::getInstance(); $results = $dispatcher->trigger( 'onContentBeforeDisplay', array( $db->insertid()) ); $results = $dispatcher->trigger( 'onContentAfterDisplay', array( $db->insertid()) );

Second Attempt:
Code:
global $mainframe; include_once('components/com_content/models/article.php'); include_once('components/com_content/helpers/query.php'); $dispatcher =& JDispatcher::getInstance(); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $item=new JObject; $item->params = clone($mainframe->getParams('com_content')); $item->context = "com_content.article"; JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentBeforeDisplay', array (& $item->context, & $text, & $item->params, $limitstart)); $dispatcher->trigger('onContentAfterDisplay', array (& $item->context, & $text, & $item->params, $limitstart)); $dispatcher->trigger('onPrepareContent', array (& $text, & $item->params, $limitstart)); $dispatcher->trigger('onAfterDisplayContent', array (& $text, & $item->params, $limitstart));
Last edit: 11 years 4 months ago by Shynx.

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

More
11 years 10 months ago #2 by Matias
This would be much easier to do in Kunena 2.0, but check createTopic() or createThread() function inside discuss plugin. Also look back where it was called as I believe that article to kunena binding was done outside of that function.
The following user(s) said Thank You: Shynx

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

More
11 years 10 months ago - 11 years 10 months ago #3 by Shynx

Matias wrote: This would be much easier to do in Kunena 2.0, but check createTopic() or createThread() function inside discuss plugin. Also look back where it was called as I believe that article to kunena binding was done outside of that function.


yeah, createTopic() did the trick for me. thank you very much for the notch in the right direction :)

in case anybody wants to know how i implemented it:
Code:
jimport ( 'joomla.plugin.plugin' ); // not sure if neccessary function createTopic($row, $catid, $subject) { //$this->debug ( "showPlugin: Create topic!" ); require_once ('components/com_kunena/lib/kunena.posting.class.php'); $message = new CKunenaPosting ( $row->created_by ); $options = array(); $fields ['subject'] = $subject; $fields ['message'] = "[article=intro]{$row->id}[/article]"; $fields ['time'] = JFactory::getDate(isset($row->publish_up) ? $row->publish_up : 'now')->toUnix(); $success = $message->post ( $catid, $fields, $options ); if ($success) { $newMessageId = $message->save (); } // We'll need to know about the new Thread id later... return $newMessageId; } // article insert in sql blabla... // $title="whatever title"; // $catid=31; //whatever kunena category i want to post in $query = "SELECT * FROM #__content WHERE id=".$db->insertid(); $db->setQuery($query); $row = $db->loadObject(); $result = createTopic($row, $catid, $title); // create cross-reference in kunenadiscuss // get thread id $query = "SELECT thread FROM #__kunena_messages WHERE id=".$msg_id; $db->setQuery($query); $thread_id = $db->loadResult(); // insert $query = "INSERT INTO #__kunenadiscuss (content_id, thread_id) VALUES (".$article_id.", ".$thread_id.")"; $db->setQuery($query); $db->query();

cheers
Last edit: 11 years 10 months ago by Shynx.

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

More
11 years 4 months ago #4 by Shynx
hey again,

im in the process of updating my little plugin for kunena2, so i am again faced with the problem stated in my original post.

the kunenadiscuss plugin seems to offer some insights, the solution i deducted from there doesnt seem particularly stable. and since Matias told me it should be easier with kunena 2, i'd like to repeat my previous question for a j2.5/kunena2 setup.

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

Time to create page: 0.390 seconds