1
Bvads
Editing Memberlist module and having search members find new inputs...
  • 2007/2/8 18:41

  • Bvads

  • Just popping in

  • Posts: 1

  • Since: 2007/2/7 2


We have setup a website using XOOPS and are looking to use this for a few things. One goal is to get 80+ users to sign up to our XOOPS site and fill in information that we want.

The standard 'user information' when you sign up includes YIM, AIM, ICQ and a host of other inputs that are useless to us. Instead of those we need to add our own set of inputs, with the purpose that our users will now be able to search for other users and find more information about them.

We tried formulize and reg codes, but after much studying, it seems that we can't get those to work with the search members feature even though we can get them to work when signing up. We don't want the user to have to enter a form to search for info, we want the search members feature to do this.

We have found the template file for search members and are able to comment out the lines that do affect each entry when you create an account. As an example, we can remove the YIM input box all together and not allow the users to sign up with that info.

What we need now is to ADD input boxes. So, replacing the YIM handler info, with say, MemberID, in the php we could theoretically create the fields we need.

Is this the only way to do this? Manually change the PHP code and remove all of the instances of non-used input fields when signing up? Then going through and manually adding all the other 20+ fields we want the user to input?

There may be a simple solution to this, we may even have it, but after the amount of time I have been staring at it, my brain is fried.

Question in a nutshell: We want to edit the info a user enters when signing up, and make this searchable using search members. How?

Any comments or help will be much appreciated.

2
jegelstaff
Re: Editing Memberlist module and having search members find new inputs...

It wouldn't be too hard to modify the xoopsmember module to also integrate with the custom form you would create in Formulize. Since you're looking at a major hack anyway to get any sort of customization in there, I suggest you stick with using Formulize and Reg Codes, and build up some code in the xoopsmember module that works nicely with the custom profile form.

The way it would have to work would be something like this...

// in the area where the form is drawn, comment out the 
// unused fields, and add something like this:

// determine which form the "User Profile" is
$module_handler =& xoops_gethandler('module');
$formulizeModule =& $module_handler->getByDirname("formulize");
$formulizeConfig =& $config_handler->getConfigsByCat(0$formulizeModule->getVar('mid'));
$profileFormID $formulizeConfig['profileForm'];

// get a series of element objects from that form:

$groups $xoopsUser $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$formulize_mgr =& xoops_getmodulehandler('elements''formulize');
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('ele_display'1), 'OR');
foreach(
$groups as $thisgroup) {
  
$criteria->add(new Criteria('ele_display''%,'.$thisgroup.',%''LIKE'), 'OR');
}
$criteria->setSort('ele_order');
$criteria->setOrder('ASC');
$elements =& $formulize_mgr->getObjects2($criteria,$profileFormID);

// $elements is an array of element objects, one object per
// element in the custom profile form.
// Now simply loop through the elements and add a search box
// to the form for each one:

foreach($elements as $element) {
  
// put code here to add an HTML textbox to the search form
  // for each field that you want to search in the profile 
  // form.
  // You will need to somehow include the element ID number 
  // of each element so you can search that element later 
  // when you have received the search form submission.

  // example, print 'Search "[element caption]":' and then 
  // put in a textbox:

  
print 'Search "' $element->getVar('ele_caption') . '":';
  print 
'$element->getVar('ele_id') . '" />';

  
// Actually, since the xoopsmember search form is  
  // generated from a XOOPS form object, you couldn't do
  // direct HTML like above, you'd have to use that info to
  // create an element object to add to the XOOPS form 
  // object that is going to appear on the screen.

  // But the important part is that we assume we're getting
  // $_POST['formulize_ele_XX'] back from this form, where 
  // XX is the ID number of the element in the custom 
  // profile form that we need to search

}

// So on the receiving end, once a user has submitted a 
// search request, you will have to make sure that the 
// "formulize_ele_XX" submissions don't mess up the normal 
// search parameters.  That could be done by looping through
// $_POST right away and sticking all the Formulize-based
// search requests in a separate array:

$formulizeSearches = array();
foreach(
$_POST as $key=>$value) {
  if(
substr($key014) == "formulize_ele_")  {
    
$elementID substr($key14); // isolate the XX part
    
$formulizeSearches[$elementID] = $value;
    unset(
$_POST[$key]); // remove this from $_POST
  
}
}

// Then, you just need to search the profile form with the
// Formulize search data identified above, if any:

// if there actually are searches on the custom fields...
if(count($formulizeSearches) > 0) {

// include the Formulize data extraction layer:
include_once XOOPS_ROOT_PATH "/modules/formulize/include/extract.php";

// build a filter string compatible with the getData 
// function in the extraction layer:

$filterContents = array();
foreach(
$formulizeSearches as $elementID=>$searchTerm) {
  
$filterContents[] = $elementID "/**/" $searchTerm;
}
if(
count($filterContents) > 1) {
  
$filter implode("][" $filterContents);
} else {
  
$filter $filterContents[0];
}

// search the user profile form 
$userData getData(""$profileFormID$filter)

// $userData is now an array of results from the custom 
// profile field.  You will have to get a list of user IDs 
// that correspond to each found entry.

$foundUserID = array();
foreach(
$userData as $thisUser) {
  
$foundUserID[] = display($thisUser"uid");
}

// end of "if(count($formulizeSearches) > 0)"

// Now you just need to make sure that all the user IDs
// collected in $foundUserID are processed by the normal
// query to the user database table -- the one xoopsmembers
// already does based on the non-custom profile criteria.
// That way, data for these found users will appear on 
// screen just like normal.


Lots of text, but mostly comments. Exactly how it gets integrated into the xoopsmembers module, well, that's a bit more work, and why I just wrote this up here instead of actually hacking it into the module. But someone with fair PHP skills should be able to make it work (if we don't bother to do it ourselves first).

I hope this helps.

--Julian
Technical Architect - Freeform Solutions
Formulize - custom registration forms, ad hoc forms and reports

Login

Who's Online

420 user(s) are online (366 user(s) are browsing Support Forums)


Members: 0


Guests: 420


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits