Thomas Varghese Thomas Varghese Thomas Varghese Thomas Varghese Thomas Maliackal

forex trading logo


Home Community General Discussions Making development changes to Latest Pos...
 Support Forum :: General Discussions
Welcome Guest   [Register]  [Login]
 Subject :Making development changes to Latest Posts.. 2009-07-14 07:15:24 
deejay
Fresher
Joined: 2009-06-09 21:35:07
Posts: 7
Location

Hi

i would like to add a feature to the 'latest posts' module.  Where in the module we can choose a 'forum_id' where these posts are displayed from.  

! before I go on I should state I have not made any components for Joomla before so am trying to get my head around the structure.

So far I have managed to add the parameter to mod_ccboard_latest_posts.xml ->

 

<param type="text" name="ForumID" label="Forum_id" default="0" description="Select the Id of the forum you wish to display" class="ccboard"  />
    </param>



Now i think I need to extend JElement as mentioned here
http://docs.joomla.org/Creating_custom_template_parameter_types

Could anyone tell me where the parameter 'numposts' is built for ccboard latest post module, as I can't seem to find it.  If i could I feel it would give me enough of a clue to do the rest.  


Beyond this is it then just a case of making changes to helper.  I'm guessing something like this might put me in the right direction.  


class ccboardLatestPostsHelper
{
    function getItems($numposts, $forumid)
    {
        $user = &JFactory::getUser();
        $db = &JFactory::getDBO();

        if ( $numposts < 1) {
            return;
        }

if ($forumid == '0'){
$forumid = '%'

}

        $db = &JFactory::getDBO();
        $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.forumid = ' .$forumid.' ' .
                    'ORDER BY p.post_time DESC';

        $db->setQuery($query, 0, $numposts);
        return ($items = $db->loadObjectList())?$items:array();
    }

}




Thanks for any help you may be able to give. 

IP Logged
 Subject :Re:Making development changes to Latest Posts.. 2009-07-14 09:18:12 
deejay
Fresher
Joined: 2009-06-09 21:35:07
Posts: 7
Location

i think i've got it sorted.  thanks to this guide http://help.joomla.org/content/view/777/125/

 will post my code up after I've got it working. 

IP Logged
 Subject :Re:Making development changes to Latest Posts.. 2009-07-15 04:36:09 
deejay
Fresher
Joined: 2009-06-09 21:35:07
Posts: 7
Location
Sorted it :)

 Heres the changes I made just incase anyone else wants to add this feature.  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


 

 

IP Logged
 Subject :Re:Making development changes to Latest Posts.. 2009-07-16 12:36:55 
thomas
Admin
Joined: 2008-12-13 17:16:30
Posts: 2,554
Location: Aluva, India
 

Hi,

Thank you for valuable effort and help.

Thanks

Thomas

 

IP Logged
Together we can make history :star:
Page # 


Powered by ccBoard



Latest News

Latest Posts

More...


Popular Posts


Powered by Joomla!. Designed by: Joomla Template, url. Valid XHTML and CSS.

© 2008-2009 CODECLASSIC.ORG. All Rights Reserved.

) { echo