Download & Extend

Remove the content search -> only user profile search

Project:ProfilePlus
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:James Marks
Status:closed (fixed)

Issue Summary

Hey,

I have installed the profile plus module and search works well. But now I would like to remove the content search so that you can only search for user profiles. How can I do that ?

Thanks for your help!

Comments

#1

Trust me I really am no coder, and I don't pretend to know what I am doing. But I managed to remove the content tab simply by adding in to the code that removes the user tab the following:

themename_removetab('Content', $vars);

Interestingly I never had to add my theme name in to this (where it says add replace themename with your theme's name).

As I say I know nothing about coding so accept no responsibility for any of this. But it worked for me! :-)

//-- start

/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
if ($hook == 'page') {
themename_removetab('Users', $vars); // replace themename with your theme's name
themename_removetab('Content', $vars);
return $vars;
}
return array();
}

/**
* Removes a tab
*/
function themename_removetab($label, &$vars) { // replace themename with your theme's name
$tabs = explode("\n", $vars['tabs']);
$vars['tabs'] = '';

foreach($tabs as $tab) {
if(strpos($tab, '>' . $label . '<') === FALSE) {
$vars['tabs'] .= $tab . "\n";
}
}
}

//-- end

#2

does this thing even work on drupal 6
i installed that module on drupal 6 but does n't seems to work

#3

subscribing - I need it in drupal 6 as well

#4

Hi,
This works on a drupal 6 site using the 6.x-1.x dev . I currently have it running on a live site. I also added a patch in order to get the search from a block.

You do need to enable the search module and the profile module for this to work.

#5

Priority:critical» normal
Status:active» fixed

#6

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#7

How do you get this to work? I'm looking to remove the content tab from the search results.

#8

Assigned to:JoachimK» James Marks
Status:closed (fixed)» fixed

The instructions for removing tabs are in the README.txt that comes with the module. In order to remove a tab, you have to modify your theme's template.php file.

  1. If your template file.php file already has the _phptemplate_variables() function, modify it to add the two 'themename_removetab()' function calls as shown below. If it doesn't have the _phptemplate_variables() function, copy the example below and add it to your template.php file.
  2. Copy the 'themename_removetab()' function and add it to your template.php file
  3. Replace every instance of 'themename' in the function and function calls with your theme's name

/**
* Override or insert PHPTemplate variables into the templates.
*/
function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {

    // Add this funtion call to remove the 'Users' tab
    themename_removetab('Users', $vars);    // replace themename with your theme's name

    // Add this funtion call  to remove the 'Content' tab
    themename_removetab('Content', $vars);  // replace themename with your theme's name

    return $vars;
  }
  return array();
}

/**
* Add this function to remove tabs
*/
function themename_removetab($label, &$vars) {  // replace themename with your theme's name
  $tabs = explode("\n", $vars['tabs']);
  $vars['tabs'] = '';
  foreach($tabs as $tab) {
    if(strpos($tab, '>' . $label . '<') === FALSE) {
      $vars['tabs'] .= $tab . "\n";
    }
  }
}

#9

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.