Advertisement:

Author Topic: Modify mlist to include custom field  (Read 2733 times)

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Modify mlist to include custom field
« on: January 31, 2018, 11:31:55 AM »
We have custom profile fields enable to include "real name" and "character name". My end-goal is to modify the View Members list (http://SITE/index.php?action=mlist) to include those fields on display.

I did a quick search and have not found a mod for this (there are a lot to look through), but I'm fairly comfortable (and I have a test forum) with modifying the view on the page to include this (I keep a change-log post with all changes made in the event we need to un-do or re-do for updates).

Has anyone done this successfully?  I am not far enough along yet to post code snippets. I just did not want to reinvent the wheel if I did not have to.  I plan on making another attempt at code changes tonight.


Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #2 on: February 03, 2018, 04:27:12 PM »
The old mod is here.   No-one, who has posted, has been able to get it working on 2.0.15.  If you get your code up and running I'd be interested in having a look.  What I'm interested in is having those fields show in search results of the member list.

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Re: Modify mlist to include custom field
« Reply #3 on: February 23, 2018, 01:55:04 PM »
Just FYI to keep everything in the correct place: https://www.simplemachines.org/community/index.php?topic=481160.new#new

I'm going to mark this resolved and put my notes in that thread.

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Re: Modify mlist to include custom field
« Reply #4 on: March 27, 2018, 10:42:38 AM »
I was incorrect in posting on the other thread. I've re-opened this topic, if that is allowed, to track.If this is not the correct location - please tell me exactly where you want me to post.

Notes:

I've updated the changes to account for 2.0.15. However, I'm running into the install issue:

Error:
Code: [Select]
Table 'SCHEME.custom_fields' doesn't exist
File: /PATH/Packages/temp/install.php
Line: 16

Line 16 of install.php:
Code: [Select]
$columns = $smcFunc['db_list_columns']('custom_fields');
First, I feel we are missing the database prefix.  My table should be SCHEME.testing_custom_fields.  Okay, I can fix that.

Second, and this is a dumb question I am sure. Are we -looking- for or -adding- "custom_fields".  If we are looking for - I believe it should be "cf_" or "cust_"  Or, I'm not understanding what this line should be doing.

Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #5 on: March 27, 2018, 07:46:28 PM »
Hi thunderchild

Thanks for your work on this so far.  A lot of people have been asking for custom fields to be included in the member list and various permutations of this.  Doesn't seem to be an area where others are really enthusiastic to help though, perhaps it's more difficult than it seems?  Regardless my experience here is that the community is very helpful and generous in giving time, so I'm hopeful about this one.

Thanks again : )

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Re: Modify mlist to include custom field
« Reply #6 on: May 01, 2018, 11:46:54 AM »
Got this working in a bastardized format -but it works. Someone with more time and better programming skills could probably clean this up.

On "install.php"
Line 16 and Line 19 need to have the table prefix added.
(I manually added my table prefix)


On "modification.xml"
Line 22/23 changes from;
Code: [Select]
<search position="replace"><![CDATA['can_search' => 'int', 'bbc' => 'int', 'mask' => 'string',]]></search>
<add><![CDATA['can_search' => 'int', 'bbc' => 'int', 'mask' => 'string', 'show_mlist' => 'int',]]></add>
to:
Code: [Select]
<search position="replace"><![CDATA['bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'placement' => 'int',]]></search>
<add><![CDATA['bbc' => 'int', 'mask' => 'string', 'enclose' => 'string', 'show_mlist' => 'int', 'placement' => 'int',]]></add>

Line 26/27 changes from:
Code: [Select]
<search position="replace"><![CDATA[$can_search, $bbc, $mask,]]></search>
<add><![CDATA[$can_search, $bbc, $mask, $show_mlist,]]></add>
to:
Code: [Select]
<search position="replace"><![CDATA[$bbc, $mask, $enclose, $placement,]]></search>
<add><![CDATA[$bbc, $mask, $show_mlist, $enclose, $placement,]]></add>

Line 40/41 changes from:
Code: [Select]
<search position="replace"><![CDATA[can_search, bbc, mask]]></search>
<add><![CDATA[can_search, bbc, mask, show_mlist]]></add>
to:
Code: [Select]
<search position="replace"><![CDATA[bbc, mask, enclose, placement]]></search>
<add><![CDATA[bbc, mask, show_mlist, enclose, placement]]></add>


Line 157-168 changes from:
Code: [Select]
<search position="replace"><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</td>]]></search>
<add><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</td>
</tr><tr class="windowbg2">
<td width="50%">
<b>', $txt['custom_edit_mod_mlist'], ':</b>
<div class="smalltext">', $txt['custom_edit_mod_mlist_desc'], '</div>
</td>
<td width="50%">
<input type="checkbox" name="mlist" ', $context['field']['mlist'] ? 'checked="checked"' : '', ' class="check" />
</td>]]></add>
to:
Code: [Select]
<search position="replace"><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />]]></search>
<add><![CDATA[ <input type="checkbox" name="display" id="display" ', $context['field']['display'] ? 'checked="checked"' : '', ' class="check" />
</dd>
<dt>
<strong>', $txt['custom_edit_mod_mlist'], ':</strong><br />
<span class="smalltext">', $txt['custom_edit_mod_mlist_desc'], '</span>
</dt>
<dd>
<input type="checkbox" name="mlist" ', $context['field']['mlist'] ? 'checked="checked"' : '', ' class="check" />
</dd>]]></add>


Line 173-190 changes from:
Code: [Select]
<search position="replace"><![CDATA[ echo '
</tr>';
}
}
// No members?]]></search>
<add><![CDATA[ // Any custom fields to show?
if (!empty($context['custom_profile_fields']['columns']))
{
foreach ($context['custom_profile_fields']['columns'] as $key => $column)
echo '
<td class="windowbg" align="left">', $member['options'][substr($key, 5)], '</td>';
}

echo '
</tr>';
}
}
// No members?]]></add>
to:
Code: [Select]
</tr>';
}
}
// No members?]]></search>
<add><![CDATA[ // Any custom fields to show?
if (!empty($context['custom_profile_fields']['columns']))
{
foreach ($context['custom_profile_fields']['columns'] as $key => $column)
echo '
<td class="windowbg" align="left">', $member['options'][substr($key, 5)], '</td>';
}

echo '
</tr>';
}
}
// No members?]]></add>


I've packed it up if someone wants to give it a try - Assuming I'm asking for help in the correct manner.

I've used this package on my test forum and my production one.  I did have to modify a theme file on my test site but not my production. It was the same changes made to line 156-166 above.
« Last Edit: May 01, 2018, 04:06:53 PM by Kindred »

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,216
  • Gender: Male
    • Kindred-999 on GitHub
Re: Modify mlist to include custom field
« Reply #7 on: May 01, 2018, 04:07:34 PM »
attachment removed.

the existing mod license does not allow for modification/redistribution.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #8 on: May 01, 2018, 06:48:35 PM »
Hi Kindred

What is the process for modifying a SMF rule under exceptional circumstances?

There have been numerous requests over time for this mod to be upgraded.  I do appreciate the effort thunderchild has gone to in this instance.  I needed this functionality so badly that I have made several topic posts asking for 'versions' of it.  Several months ago (actually I think it was last year) I sent a PM to the mods author offering to pay for an upgrade, I checked and he was around at the time, there was no reply to my PM.

So just wondering if there is a process in the SMF rules to handle circumstances such as these?

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Re: Modify mlist to include custom field
« Reply #9 on: May 01, 2018, 06:53:09 PM »
I was not trying to viloate any license, just trying to get the mod to work in the latest version. I agree with Pepe...how should we handle these situations?

(My phone autocorrected Pepe's name, edit was to fix that)

Online GigaWatt

  • Support Team Apprentice
  • Full Member
  • ***
  • Posts: 505
  • Gender: Male
    • Macedonian electronics forum
Re: Modify mlist to include custom field
« Reply #10 on: May 01, 2018, 07:12:06 PM »
Hint: You could post it on any other site ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Offline Sir Osis of Liver

  • SMF Hero
  • ******
  • Posts: 7,799
  • There's someone in my head but it's not me.
Re: Modify mlist to include custom field
« Reply #11 on: May 01, 2018, 07:25:16 PM »
Think I did this for someone not long ago, wasn't that difficult.  You just want to add a couple of columns to memberlist for custom profile fields?

Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #12 on: May 01, 2018, 07:36:46 PM »
Think I did this for someone not long ago, wasn't that difficult.  You just want to add a couple of columns to memberlist for custom profile fields?

Yes, but to also have them display in search results on the membership list.

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,216
  • Gender: Male
    • Kindred-999 on GitHub
Re: Modify mlist to include custom field
« Reply #13 on: May 02, 2018, 07:17:40 AM »
Hi Kindred

What is the process for modifying a SMF rule under exceptional circumstances?

There have been numerous requests over time for this mod to be upgraded.  I do appreciate the effort thunderchild has gone to in this instance.  I needed this functionality so badly that I have made several topic posts asking for 'versions' of it.  Several months ago (actually I think it was last year) I sent a PM to the mods author offering to pay for an upgrade, I checked and he was around at the time, there was no reply to my PM.

So just wondering if there is a process in the SMF rules to handle circumstances such as these?


Unfortunately, there is nothing we (SMF) can do about it.
The license is restrictive -- no redistribution.
therefore, you can give instructions on how to modify the mod, but you can not package it up.

although there may be many people asking for it, this does not change the basic IP rights/requirements.

Hint: You could post it on any other site ;).

No, actually, posting on another site would STILL be a violation of the IP rights of the original author, based on the license of the mod.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #14 on: May 02, 2018, 08:32:30 AM »

Unfortunately, there is nothing we (SMF) can do about it.
The license is restrictive -- no redistribution.
therefore, you can give instructions on how to modify the mod, but you can not package it up.

although there may be many people asking for it, this does not change the basic IP rights/requirements.

Perhaps contacting the author, explaining that the mod is now unsupported and not working on current SMF versions ... asking if under these circumstances he/she would consider relaxing the IP restrictions.

Also considering making more flexible arrangements like this a more standard practice in future?

Additionally consider having this flexibility in original IP agreements?

There must be ways to make these types of situations more generally helpful for the entire community.

Offline Illori

  • Project Manager
  • SMF Master
  • *
  • Posts: 49,239
Re: Modify mlist to include custom field
« Reply #15 on: May 02, 2018, 08:36:19 AM »
take a look at https://www.simplemachines.org/community/index.php?topic=461016.0, we are following the law. we cannot just relax or change this without the author changing the license.

Offline pepa

  • Jr. Member
  • **
  • Posts: 190
Re: Modify mlist to include custom field
« Reply #16 on: May 02, 2018, 08:42:46 AM »
take a look at https://www.simplemachines.org/community/index.php?topic=461016.0, we are following the law. we cannot just relax or change this without the author changing the license.

Yep, that's one of the things I was suggesting ... asking the author to change the license.  People and circumstances change over time, even though an author may select an exclusive IP license at some time they may agree to change it later when circumstances are different ... can't hurt to ask.

Online Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 56,216
  • Gender: Male
    • Kindred-999 on GitHub
Re: Modify mlist to include custom field
« Reply #17 on: May 02, 2018, 08:48:21 AM »
but that is not the responsibility of SMF.  If any user wants to take up modification and support of a mod, then they are free to attempt to contact the original author.

as for flexibility...   we do ask the authors is a clear license.
Some do release with BSD, MIT or other license that allows modification and redistribution. Some don't. The choice is up to each author, and is, again, not SMF's responsibility (except to enforce said license, especially on our site).

Mods which were released before a clear license was required fall into the "most restrictive license" category - because that's how IP law works.


So -- TL;DR
If you want to change the license or modify the mod, then it is up to you to contact the author
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline Pipke

  • Full Member
  • ***
  • Posts: 431
    • [NRNS]
Re: Modify mlist to include custom field
« Reply #18 on: May 02, 2018, 09:50:49 AM »
You could make your own new mod/package and add it to the mod site.

http://wiki.simplemachines.org/smf/Customization_approval_guidelines

Offline thunderchld

  • Semi-Newbie
  • *
  • Posts: 67
Re: Modify mlist to include custom field
« Reply #19 on: May 02, 2018, 10:10:08 AM »
I'll refrain from making my own new mod and package it as I'm sure I'll violate something else at the rate I'm going.   I'll leave what i have up and just try and work with in the confines of core SMF going forward.