Hi,
I want to achieve the same as Stefan did in this thread:
www.jomsocial.com/forum/design-and-custo...om-list?limitstart=0
Our members will need to be able to create lots of private groups, for which they are responsible for inviting other members to join. Its impractical to have them all displaying in the main group listings as there will be thousands. I want them to be hidden to none group members, and Stefan's code changes seem to be what's needed. However, before I go ahead and mess with the file I have a couple of questions.
It isn't clear if Stefan added the new code to the file specified, or if he replaced a block of code with his reworked version.
The file he modified is: components/com_community/templates/default/groups.list.php
The code he provided is:
$user = CFactory::getUser();
$groupsUserIsIn = JAccess::getGroupsByUser(JFactory::getUser()->id);
if(in_array(7,$groupsUserIsIn) || in_array(8,$groupsUserIsIn))
{
$isAdmin = true;
}else{
$isAdmin = false;
}
?>
<a id="lists" name="listing"></a>
<div class="cLayout">
<?php
if( $groups )
{
$groupsModel =& CFactory::getModel( 'groups' );
?>
<ul class="cIndexList forGroups cResetList">
<?php
for( $i = 0; $i < count( $groups ); $i++ )
{
$group =& $groups[$i];
$isMember = $groupsModel->isMember( $user->id , $group->id );
if($isAdmin || $group->categoryid != 4 || ($group->categoryid == 6 && $isMember)){<?php
} <---
}
?>
$config = CFactory::getConfig();
?>
<a id="lists" name="listing"></a>
<div class="cLayout">
<?php
if( $groups )
{
?>
<ul class="cIndexList forGroups cResetList">
<?php
for( $i = 0; $i < count( $groups ); $i++ )
{
$group =& $groups[$i];
?>
<li class="<?php echo $group->approvals == COMMUNITY_PRIVATE_GROUP?'group-private':'group-public'?>">
<div class="cIndex-Box">
<a href="<?php echo CRoute::_( 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id );?>" class="cIndex-Avatar cFloat-L">
<img src="<?php echo $group->getThumbAvatar();?>" alt="<?php echo $this->escape($group->name); ?>" class="cAvatar" />
<?php
if($group->approvals == COMMUNITY_PRIVATE_GROUP)
{
echo '<b class="cStatus-Private">'.JText::_('COM_COMMUNITY_GROUPS_PRIVATE').'</b>';
}
?>
</a>
<div class="cIndex-Content">
<h4 class="cIndex-Name cResetH">
<a href="<?php echo CRoute::_( 'index.php?option=com_community&view=groups&task=viewgroup&groupid=' . $group->id );?>">
<?php echo $this->escape($group->name); ?>
</a>
</h4>
<div class="cIndex-Meta small"><?php echo JText::sprintf('COM_COMMUNITY_GROUPS_CREATE_TIME_ON' , JHTML::_('date', $group->created, JText::_('DATE_FORMAT_LC')) );?></div>
<div class="cIndex-Status"><?php echo ($config->get('allowhtml')) ? $group->description : $this->escape($group->description); ?></div>
<div class="cIndex-Actions clearfix">
<div>
<i class="com-icon-groups"></i>
<a href="<?php echo CRoute::_( 'index.php?option=com_community&view=groups&task=viewmembers&groupid=' . $group->id ); ?>"><?php echo JText::sprintf((CStringHelper::isPlural($group->membercount)) ? 'COM_COMMUNITY_GROUPS_MEMBER_COUNT_MANY':'COM_COMMUNITY_GROUPS_MEMBER_COUNT', $group->membercount);?></a>
</div>
<?php if($config->get('creatediscussion') ){?>
<div>
<i class="com-icon-comment"></i>
<?php echo JText::sprintf((CStringHelper::isPlural($group->discusscount)) ? 'COM_COMMUNITY_GROUPS_DISCUSSION_COUNT_MANY' :'COM_COMMUNITY_GROUPS_DISCUSSION_COUNT', $group->discusscount);?>
</div>
<?php }?>
<div>
<i class="com-icon-wall"></i>
<?php echo JText::sprintf((CStringHelper::isPlural($group->wallcount)) ? 'COM_COMMUNITY_GROUPS_WALL_COUNT_MANY' : 'COM_COMMUNITY_GROUPS_WALL_COUNT', $group->wallcount);?>
</div>
<?php
if( $isCommunityAdmin && $showFeatured )
{
if( !in_array($group->id, $featuredList) )
{
?>
<div class="cIndex-Feature">
<a onclick="joms.featured.add('<?php echo $group->id;?>','groups');"
href="javascript:void(0);"
class="btn Icon"
title="<?php echo JText::_('COM_COMMUNITY_MAKE_FEATURED'); ?>">
<i class="com-icon-award-plus"></i>
</a>
</div>
<?php
}
}
?>
hi Melanie,
I need your conformation for this, so do you want the private groups will be hidden for the non-members of that group? in another words the private groups only will be shown for only that members?
Because the solution can be different than Stefan's issue
thank you
Hi Mel,
Please you open again this file components/com_community/templates/default/groups.list.php, find this code :
$group =& $groups[$i];
$group =& $groups[$i];
$user = CFactory::getUser();
$groupsModel =& CFactory::getModel( 'groups' );
$isMember = $groupsModel->isMember( $user->id , $group->id );
if(!$isMember && $group->approvals == COMMUNITY_PRIVATE_GROUP) continue;
Dimas,
That works beautifully :)
Do you think this could be added as a feature in future releases (maybe as mentioned earlier with the option to make them invisible during group creation?).
Thanks so much for your help.
Mel
Hi Mel,
No it won't, I suggest you move your hack file to the override template folder, read here
documentation.jomsocial.com/wiki/Customizing_Template