We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Show total topics on group list (group side) | Forum

dave Leader
dave May 18 '14
Rmemeber that once you click on a group name everything changes hands over to the forum plugin side process. 


So this mod is for the group plugin side of things which is why it is more difficult because we dont have the luxury of having all the needed functions within the group plugin as we do with the forum plugin. 


Issue: On the group list i would like to show how many topics are in each group next to the total members output.   This will allow visitors to see how many topics are in a group without clicking on each group, it will also show same on the group widget on the main page. 


Example:   11 members  # topics in group


see image...














thanks 



The Forum post is edited by dave May 19 '14
dave Leader
dave May 18 '14
Well so far here is what i have, im close i think but its not showing the total value integer.. 

THIS IS NOT WORKING YET SO PLEASE DONT USE THIS YET... 


I am beginning to understand why they didnt do this.  Most everything other than group listing, create, edit group and users is done on the forum plugin side.  So in order to show the total i have to either call or move functions from forum side to group side...  But i will get this done i hope before i give up...  


If anyone would like to help i would welcome it...  thanks


I think the problem might be in the params set up or the example function process not sure yet. 



SEE THE DB ERROR IMAGE BELOW... 










But here is what i have so far. 


php files modded: 


So working backwards it all starts at the dao i believe.. 


groups/bol/groups_group.dao.php  
ADDED THIS:


// group list total topic mod start


    /**

     * Returns forum group's topic count

     * 

     * @param int 

     * @return int $groupId

     */

    public function findGroupTopicCount( $groupId )

    {

        $example = new OW_Example();


        $example->andFieldEqual('groupId', (int) $groupId);


        return $this->countByExample($example);

    }

// group list total topic mod end



And then service php calls the dao function


service.php


ADDED 


// group list total topic mod start


    /**

     * Returns group's topic count

     * 

     * @param int $groupId

     * @return int

     */

    public function getGroupTopicCount( $groupId )

    {

        return $this->groupDao->findGroupTopicCount($groupId);

    }


// group list total topic mod end 



ow_plugins/groups/components/groups_widget.php


 inside the private function assignList


AFTER: 


               'users' => $userCountList[$item->id]

            );



ADDED THIS:


// group list total topic mod start

$GtopicCount = 0;


$GtopicCount = $this->service->getGroupTopicCount($item->id);  //(GIVES ME DB ERROR CANT FIND groupId)


$this->assign('GtopicCount', $GtopicCount); 

// group list total topic mod end





And then the controller sets the value in smarty for html usage


ow_plugins/groups/controllers/groups.php


inside the function mostPopularList  (i know i have to add this also to the other list functions but i wont until i get this working)


AFTER THIS: 


     $listCount = $this->service->findGroupListCount(GROUPS_BOL_Service::LIST_MOST_POPULAR);



ADDED THIS:


// group list total topic mod start


$groupId = (int) $params['groupId'];


$GtopicCount = $this->service->getGroupTopicCount($groupId); //ALSO GIVES ME DB ERROR CANT FIND groupId


$this->assign('GtopicCount', $GtopicCount); 


// group list total topic mod end 



HTML MODS 


/ow_plugins/groups/views/controllers/groups_list.html (groups menu display)


inside the foreach loop added this



<!-- group list total topic mod start -->
<div style="padding-left:65px;"># total topics {$GtopicCount}<br /><br /></div>
<!-- group list total topic mod end -->

componets/groups_widget.html  (this is for the main page display widget)
in two places after displays the member totals for the group, so:AFTER THIS:  2X{text key="groups+listing_users_label" count=$item.users}

ADDED THIS                             

 <!-- group list total topic mod start -->
&nbsp;&nbsp; # total topics {$GtopicCount}
<!-- group list total topic mod end -->

Note: I will do a lang key or make the text look better when im done. 


The Forum post is edited by dave May 19 '14
dave Leader
dave May 19 '14
Any ideas, im not sure why its not finding the groupId in the table. 


I suspect it has something to do with calling this function from the groups side as it works fine on the forum side. 


return $this->countByExample($example);


which is in ow_core/base_dao.php

The Forum post is edited by dave May 19 '14
dave Leader
dave May 19 '14
I think i might have it..   if i am correct, i just need a topic dao over on the group side so that i can assign $example to the "form topic " table.  i think thats why it cant find the groupId.  


However im not sure if i need a topic php as well.. 

dave Leader
dave May 19 '14
I have not converted topic_dao and topic php files over to the groups BOL and converted the in side of the file to be GROUPS... I have also modified the service.php in groups to add the new class call and getinstance call.  


So now i have no more DB error but im still not getting the values.  

dave Leader
dave May 20 '14
Im getting the values but they are all mixed up... not sure why.. 


Im working on the main page group widget first.  


there are two list options "latest" which is default.. and  "popular"  so by default the group list has two arrays out of the oxwall box, one for each list type.. 


If i run the array for the group list (standard ox function)  i get this 



Grouplist array for widget  (i have notated below regarding the list type but its all one result)
This is the output for the $groupIdList[]  array for the widget


$latest    (example this means that group 9 is the latest group)
Array(    [0] => 9    [1] => 8    [2] => 7    [3] => 6    [4] => 5    [5] => 4    [6] => 3    [7] => 2    [8] => 1)
$popular  (this means that group 1 is the most popular) 
Array(    [0] => 1    [1] => 2    [2] => 4    [3] => 5    [4] => 6    [5] => 7    [6] => 8    [7] => 9    [8] => 3)



no problem so far until i try to get the topic count.  


Then i try to use foreach for each group id in the array and get the topic total and store it in another array like such. 


$GtopicCountList = array();
          foreach ( $groupIdList as $key => $value)   //value is groupId

          {                 

            $GtopicCountList[] = $this->service->getGroupTopicCount($value);

            } 

            unset($key);

            unset($value);


logically the result value should match with the corresponding group array element, meaning that the first item in the loop for latest is [0] group 9 so it should store group 9 topic total in latest [0] element on the topic count side.  


BUT IT DOES NOT GRRRR.... not sure why. 


So the image below shows the group array result and the topic count result side by side.  
Any ideas whats up im perplexed on this one.



























Any help would be appreciated thanks.. 
 



The Forum post is edited by dave May 20 '14
dave Leader
dave May 21 '14
ok i found the reason.   Oxwall devs are trying to drive me to an early grave lmao... you guys LMAO 


Seems it was not my fault afterall.   I redid the oxwall core base dao countbyexample function that led me to (which i admit i should have done first)  doing the query in the phpMyAdmin


IMPORTANT:  The problem is that all of the groupId in the forum topic table are not a true reflection of the group id that you see as part of your group url id.   Forum topics and group topics are all mixed so looking for group 1 per say in the forum topics table will not get you actual group 1, it is a different number by the time it gets recorded to this table.  


I lost many hours of my life over this one lmao..   Drove me nuts.   


Now im calling a therapist to relieve my stress lmao.. 


I will get the rest of this figured out and get this wrapped up soon. 



The Forum post is edited by dave May 21 '14
Alia Team
Alia May 21 '14
Looking forward for your next post Dave =)
dave Leader
dave May 21 '14
Thanks Aliia, good to hear from you always :)  I found some object functions on the forum side that seem to be the key to sorting out groups in tables, sectionId's and all that complicated stuff to get the data needed... Well thats the game plan for now lol..  One thing for certain you typically dont end up with what you started with....  :)


I will remove the old code above and update it when i finally get done..  Please poke in once in a while if i get upside down and get stuck...  Lets keep our fingers crossed here :)

dave Leader
dave May 21 '14
well didnt take me long Aliia im stuck in the mud lol.. i need a tow lol.. 


   I need to tap into the additional param list and i dont know how. 


I believe this is key to getting done.  The customParamList is no problem they both have it (forum and groups)  But this additonalParamList is not available on the group side (this is what the forum side uses for the entity and id)  

 

        $this->entityId = (int) $paramObj->additionalParamList['entityId'];

        $this->entity = $paramObj->additionalParamList['entity'];


I checked the init and other files and i cant find what im looking for to connect groups to this list array.   I believe its originally set in the system_plugins/base/controllers/ajax_component_entity_panel.php  and has this line as the class extents command.  


class BASE_CTRL_AjaxComponentEntityPanel extends BASE_CTRL_AjaxComponentPanel


i did a search for ajax in forum and i found some stuff but nothing i could see that directly connects to the AdditionalParamList  


Any ideas what i need to add to a plugin to connect it to the data in AdditionalParamList?


The Forum post is edited by dave May 21 '14
dave Leader
dave May 23 '14
well i took some time off from this to get my head clear.  And i am one step closer which is good.   


Seems i dont need to get the value for $paramObj->additionalParamList for the group plugin, i just need it for one file and that blows my mind.  


most of the other files in group plugin components have access to that object but when i add the line to my file it does not get the info, and i am exending the same class and using the same code.  so it must be some  local group issue with this.  


i should be able to add this to any group component file and get the data 


$groupId = (int) $paramObj->additionalParamList['entityId'];


as long as i extend the class like so


class GROUPS_CMP_BriefInfoWidget extends BASE_CLASS_Widget{


and i set service as either of these 


$service = GROUPS_BOL_Service::getInstance();

or

private $service;


So i dont know why im not grabbing data from this file.. the array is empty....   has to be some local deal that forum has that group does not... very strange.. 


how do i get $paramObj->additionalParamList to work in a specific group component file when all the other component files use it and it works for them but not for mine?