HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


[RESOLVED!] Assistance or coaching request

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#96964 (In Topic #19241)
Avatar

Honoured member

I have one of the sites I manage running on OCP 8.1.6, all is well with the exception of one request that keeps coming in from site members:

In the member list, there are the standard columns displayed, see pic below



The request is to add an additional column, so that a field that's been added to the member profiles "City" displays the contents for each member



I have played with addon's and tried messing with the code and CSS file, but this is obviously beyond my ability, so...

If anyone out there has the urge to help me figure out how to make this work, I would be most grateful.



Thanks everyone, cheers!

Mark
Back to the top
 
Posted
Item has a rating of 5 (Liked by Chris GrahamLiked by superiorpyro)  
Rating:
#96982
Avatar

Community saint

Adding a column to the members list requires coding changes and not css or templates.

The directory() function in members.php needs to be modified. Looking at that code briefly, I suspect that all the coding changes need to be done within the following bit of code:

Code

      $fields_title=results_field_title(array(do_lang_tempcode('USERNAME'),do_lang_tempcode('PRIMARY_GROUP'),do_lang_tempcode('COUNT_POSTS'),do_lang_tempcode('JOIN_DATE')),$sortables,'md_sort',$sortable.' '.$sort_order);
      require_code('ocf_members2');
      foreach ($rows as $row)
      {
         $link=$GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($row['id'],true,$row['m_username']);
         if ($row['m_validated']==0) $link->attach(do_lang_tempcode('MEMBER_IS_UNVALIDATED'));
         if ($row['m_validated_email_confirm_code']!='') $link->attach(do_lang_tempcode('MEMBER_IS_UNCONFIRMED'));
         $member_primary_group=ocf_get_member_primary_group($row['id']);
         $primary_group=ocf_get_group_link($member_primary_group);

         $members->attach(results_entry(array($link,$primary_group,integer_format($row['m_cache_num_posts']),escape_html(get_timezoned_date($row['m_join_time'])))));

         $member_boxes[]=ocf_show_member_box($row['id'],true);
      }
      $results_table=results_table(do_lang_tempcode('MEMBERS'),$start,'md_start',$max,'md_max',$max_rows,$fields_title,$members,$sortables,$sortable,$sort_order,'md_sort');
Note the code above was taken from v7.0.1 (the version I am on) but its probably identical in v8.1.6.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#96989
Avatar

Honoured member

Thank you very much!  While I'm completely out of my element, I have to at least give it a try and see what I can come up with.  I will keep you posted (I'm hoping the code is the same for version 8...)

My question at this point is:  Where exactly is the members.php file located?  When I do a search, it appears to show up in multiple locations??

Cheers!

Mark


Last edit: by superiorpyro
Back to the top
 
Posted
Item has a rating of 5 (Liked by superiorpyro)  
Rating:
#96995
Avatar

Community saint

Its in the \site\pages\ folder.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#96998
Avatar

Honoured member

Ok, so I'm assuming that based on the parameters in this section, that the code would need to look something like this:

$fields_title=results_field_title(array(do_lang_tempcode('USERNAME'),(do_lang_tempcode('CITY'),do_lang_tempcode('PRIMARY_GROUP'),do_lang_tempcode('COUNT_POSTS'),do_lang_tempcode('JOIN_DATE')),$sortables,'md_sort',$sortable.' '.$sort_order);
        require_code('ocf_members2');
        foreach ($rows as $row)

I've tried to find out what the parameter name is for the custom field I've added, but I'm not sure where I can confirm that information?  Also, I would suspect that there is going to be more coding required than just adding the (do_lang_tempcode('CITY') to the $fields_title command...is that correct?  My guess based on an error issued "A language entry is missing: City" is that another file is also going to require editing...
Back to the top
 
Posted
Item has a rating of 5 (Liked by Chris GrahamLiked by superiorpyro)  
Rating:
#96999
Avatar

Community saint

The reason you are getting the "A language entry is missing: City" error is because you do note have a language string named "CITY" defined. Instead of creating and looking up a language string, just use a literal string (at least to start with). So instead of "do_lang_tempcode('CITY')" try "make_string_tempcode('City')"

That should take care of the title row.

Now for the individual member rows you will need to change the following:

Code

$members->attach(results_entry(array($link,$primary_group,integer_format($row['m_cache_num_posts']),escape_html(get_timezoned_date($row['m_join_time'])))));
to something like:

Code

$members->attach(results_entry(array($link,make_string_tempcode(get_ocp_cpf('CITY')),$primary_group,integer_format($row['m_cache_num_posts']),escape_html(get_timezoned_date($row['m_join_time'])))));

Where 'CITY' is the name of your custom profile field. I don't recall off the top of my head how to check the custom profile field names.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#97000
Avatar

Honoured member

I'm VERY grateful for your help, thank you!!

So far, all the code changes that you've suggested appear to be functioning as intended.  The "make_string_tempcode" addresses adding the column and heading to the table.

Here is how the code looks now:

Code

$fields_title=results_field_title(array(do_lang_tempcode('USERNAME'),do_lang_tempcode('PRIMARY_GROUP'),do_lang_tempcode('COUNT_POSTS'),do_lang_tempcode('JOIN_DATE'),make_string_tempcode('City')),$sortables,'md_sort',$sortable.' '.$sort_order);
        require_code('ocf_members2');
        foreach ($rows as $row)

  and:

Code

$members->attach(results_entry(array($link,$primary_group,integer_format($row['m_cache_num_posts']),escape_html(get_timezoned_date($row['m_join_time'])),make_string_tempcode(get_ocp_cpf('City')))));

  
I changed where I inserted the code because as I played with it, I realized that if I didn't, it would display the wrong content in the wrong column.

Also, I changed the name of the custom profile field above from 'CITY' to 'City' and the column immediately populated -- the issue at this point as you can see in the screen shot below:  OCP is reporting the city that I put in MY profile, for all the members instead of picking up the unique (or null if user has not specified) value.  If I change the city in my profile, it applies it to everyone when I view the member list?



Mark


Last edit: by superiorpyro
Back to the top
 
Posted
Item has a rating of 5 (Liked by superiorpyro)  
Rating:
#97002
Avatar

Community saint

Ah, change:

Code

get_ocp_cpf('City')
to

Code

get_ocp_cpf('City',$row['id'])
.

O_o I really should avoid writing code at 2 AM! O_o


Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#97007
Avatar

Honoured member

DUH!! I feel so stupid...I wasn't even paying attention enough to copy that code in after the 'City' variable, I should have seen that!

And of course, you were 100% correct and it works like a charm -- THANK YOU VERY MUCH!!! :thumbs::thumbs::thumbs:

Not only does it function exactly as I need, I've learned some new tricks along the way.

If I ever get lucky enough to visit Melbourne, dinner is on me!

Cheers,

Mark
Back to the top
 
Posted
Rating:
#97008
Avatar

Community saint

No problem, glad I could help.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: