user tip Group Search for Profile Display

PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Hey Guys,

I am adding a "My Groups" display to my sidebar (elastic skin) much like the latest followers.

I am stuck on the search params required to only show groups I own or have joined.

{jrCore_list module="jrGroup" search1="group_member_id = `$_profile_id`" search2"group_owner? = `$_profile_id`" assign="groups" template=$my_group_tpl}

I know that group_owner is wrong, but I can't see how that is stored from the data store. Plus, the group_member_id is not working either.

I hope someone can help me with this.

Thanks


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 06/02/16 05:16:08PM
michael
@michael
8 years ago
7,715 posts
Take a look at these docs:

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/development/1477/debug

The debug panel will tell you what variables you have to work with. take out some of the search stuff and put the {debug} in the $my_group_tpl template

Looking at the database structure now, you might need to create a custom smarty function to get the groups that the current profile is a member of because it looks like the members of a group are stored in their own table.

Docs: "Defining your own SMARTY function"
https://www.jamroom.net/the-jamroom-network/documentation/development/1569/defining-your-own-smarty-function

Need to see what data comes back with a debug in your template and a simple jrCore_list call:
{jrCore_list module="jrGroup" template=$my_group_tpl}

The group members might get added, you'd need to check.
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
I think I found the info I need, but I am unsure as to how to write the search syntax to search inside of an array.

group_member => Array (3)
    41 => Array (13)
      member_id => "10"
      member_created => "1456861815"
      member_user_id => "41"
      member_group_id => "5"
      member_status => "1"
      member_active => "1"
      member_more => ""
      _user_id => "41"
      user_name => "John Smith"
      _profile_id => "73"
      profile_url => "john-smith"
      profile_name => "John Smith"
      profile_quota_id => "21"

The profile_id is in there :) and we may need to search for member_active =1 first.

What do you think?


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

updated by @the-patria-company: 03/02/16 10:50:42AM
michael
@michael
8 years ago
7,715 posts
What is the name of that array? {$group_member} ??

if it is, then its:
{$group_member.41._profile_id}

or
{$group_member[41]._profile_id}

for things with nested arrays, you'd normally be looping over the container though.

{foreach $group_member as $member}
 {$member._profile_id}
 {$member.user_name}
etc....
{/foreach}

More info in the smarty docs:
http://www.smarty.net/docs/en/language.function.foreach

Docs: "{foreach}{/foreach}"
https://www.jamroom.net/the-jamroom-network/documentation/development/3142/foreach-foreach

and give the Developer Docs a skim read for interesting stuff:

Docs: "Developer -> Table of Contents"
https://www.jamroom.net/the-jamroom-network/documentation/development
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Ok, here is what I have and I think it is going to work out for now. It places a thumbnail of the group image for groups that the profile owner has created, in the side bar. Additionally, when the profile owner is viewing their profile I added a link to view Groups I Follow; thus eliminating the additional menu item in the account drop down menu (elastic skin).

[code]
{if !jrCore_is_mobile_device() && jrCore_module_is_active('jrGroup')}

{capture assign="my_groups_tpl"}
{literal}
{jrCore_module_url module="jrGroup" assign="murl"}
{if isset($_items)}
{foreach from=$_items item="item"}
<a href="{$jamroom_url}/{$item.profile_url}/{$murl}/{$item._item_id}/{$item.group_title_url}">{jrCore_module_function function="jrImage_display" module="jrGroup" type="group_image" item_id=$item._item_id size="small" crop="auto" class="img_shadow" width=58 height=58 style="padding:2px;margin-bottom:4px;" alt="{$item.group_title|jrCore_entity_string}" title="{$item.group_title|jrCore_entity_string}" _v=$item._updated}</a>
{/foreach}
{/if}
{/literal}
{/capture}

{jrCore_list module="jrGroup" profile_id = "`$_profile_id`" assign="groups" template=$my_groups_tpl}
{if strlen($groups) > 0}
<div class="block block_profile_left">
<h3>My Groups:</h3>
<div class="block_content mt10">
<div style="padding-top:8px">
{$groups}
</div>
{if jrProfile_is_profile_owner($_profile_id)}
<a href="{$jamroom_url}/group/my_groups">Groups I Follow</a>
{else}
{/if}
</div>
</div>
{/if}
{/if}
{/code]

ENJOY <img src="https://www.jamroom.net/data/media/0/0/jrSmiley_140_smiley_image.png" style="height: 20px" alt=":)">


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Can you give us a screenshot of what it looks like?
and...where did you add that code? :)


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Sure I added it to the profile_sidebar.tpl for my skin.


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Thanks! -And does clicking on each group avatar thumbnail take you to that particular group page?...the way it does with the "Latest followers' pix?- that'd certainly be an easy boost to get folks to join groups!


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Yes ma'am, it sure does :)


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3
Strumelia
Strumelia
@strumelia
8 years ago
3,603 posts
Nice work!


--
...just another satisfied Jamroom customer.
Migrated from Ning to Jamroom June 2015
PatriaCo
PatriaCo
@the-patria-company
8 years ago
349 posts
Thx :) It may need some tweaks, so if you have any suggestions, they are more than welcome.


--
The Patria Company - patriaco.com / quality-trades.com / a-t.life - doing Jamroom since v3

Tags