Wednesday 15 July 2009

Adding a feature to a Joomla Component

This is a small change I made to a ccboard ( which is an excellent Joomla forum addon by the way ) .
You will need to have the module for ccboard latest_posts.

Before I go on I found two documents online that were very helpful in understanding how to make changes to a Joomla Component
http://docs.joomla.org/Creating_custom_template_parameter_types
http://help.joomla.org/content/view/777/125/

Basically allows you to show recent posts from a specific catergory. The default '0' will show all cats.
Before you start BACKUP.



OPEN modules/mod_ccboard_latest_posts/helper.php

FIND:

function getItems($numposts)


REPLACE WITH:


function getItems($numposts, $forumid)

FIND:

if ( $numposts < 1) {
return;
}

UNDERNEATH ADD:

if ($forumid == '0' || $forumid == NULL){
$forumid = '%';
}


FIND:

$query = 'SELECT p.id, p.forum_id, p.topic_id, p.post_time, ' .
'p.post_subject, u.username, p.post_user, p.post_username ' .
'FROM #__ccb_posts AS p ' .
'INNER JOIN #__ccb_forums AS f ON f.id = p.forum_id ' .
'INNER JOIN #__users AS u ON u.id = p.post_user ' .
'WHERE f.published=1 AND f.view_for <= ' . $user->get('gid') . ' ' .
'ORDER BY p.post_time DESC';


REPLACE WITH:

$query = 'SELECT p.id, p.forum_id, p.topic_id, p.post_time, ' .
'p.post_subject, u.username, p.post_user, p.post_username ' .
'FROM #__ccb_posts AS p ' .
'INNER JOIN #__ccb_forums AS f ON f.id = p.forum_id ' .
'INNER JOIN #__users AS u ON u.id = p.post_user ' .
'WHERE f.published=1 AND f.view_for <= ' . $user->get('gid') . ' AND p.forum_id LIKE \''.$forumid.'\' ' .
'ORDER BY p.post_time DESC';


-> SAVE


OPEN modules/mod_ccboard_latest_posts/mod_ccboard_latest_posts.php

FIND:

$numposts = $params->get('numposts');

ADD UNDERNEATH:

$forumid = $params->get('ForumID');


FIND:
$items = ccboardLatestPostsHelper::getItems($numposts);

REPLACE WITH:

$items = ccboardLatestPostsHelper::getItems($numposts, $forumid);


-> SAVE

OPEN modules/mod_ccboard_latest_posts/mod_ccboard_latest_posts.xml


FIND:

ccBoard
Joomla


ADD UNDERNEATH:




-> SAVE

-> UPLOAD FILES

No comments: