Is it possible to create a block that contains the same information provided on the Saved Searches tab? Also, all of my saved searches are currently called Saved Search. Is it possible to expose a form field on the Save search block to give each search a name?

Comments

dmiric’s picture

I think this would be a right place to post this.

How about reworking this module in to a subscribe module. If you use youtube you would know how subscriptions work there.

It should have one view that shows all the results from all saved searches and filter by saved search. (I'm not sure how complicated it would be to make more searches and then aggregate them like that)

Also it would be good if you could choose from which of those you would like to recieve content in aggregated email.

Those options would make this already great module in to very powerful subscription module.

attiks’s picture

I think this is related to #1888140: Add extended Views integration

attiks’s picture

In case it helps someone

/**
 * Implements hook_block_info().
 */
function MYMODULE_block_info() {
  $blocks['MYMODULE_saved_searches'] = array(
    'info' => t('Saved searches'),
    'cache' => DRUPAL_NO_CACHE,
  );

  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function MYMODULE_block_view($delta = '') {
  $block = array();

  switch ($delta) {
    case 'MYMODULE_saved_searches':
      $block['subject'] = t('My saved searches');
      $block['content'] = MYMODULE_search_api_saved_searches_user_listing();
      break;

  }
  return $block;
}

/**
 * Block listing all saved searches of a user.
 *
 * @param $account
 *   The user of which to list saved searches.
 */
function MYMODULE_search_api_saved_searches_user_listing($account = NULL) {
  if (is_null($account)) {
    global $user;
    $account = $user;
  }
  $base_path = 'search-api/saved-search/';
  $header = array(
    t('Name'),
    t('Operations'),
  );
  $searches = search_api_saved_search_load_multiple(FALSE, array('uid' => $account->uid));
  $rows = array();
  foreach ($searches as $search) {
    if (empty($search->options['page'])) {
      $name = check_plain($search->name);
    }
    else {
      $name = $search->l($search->name);
    }
    $path = $base_path . $search->id;
    $rows[] = array(
      $name,
      l(t('delete'), $path . '/delete', array('query' => drupal_get_destination())),
    );
  }

  $render = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No searches were saved yet.'),
    '#sticky' => TRUE,
  );
  return $render;
}

Hitby’s picture

Hi Attiks, could you expand on this post please? I presume this needs to be made into a custom module?

attiks’s picture

#4 Yes you need a custom module, copy-paste all code in the .module file and replace MYMODULE with your module name

drunken monkey’s picture

With the latest version, Settings > Miscellaneous > Customizable search name should work, too.

(Oh, this answer refers to the original question. The comment in #1 is completely off-topic here.)

zilla’s picture

is there a more simple way to achieve this using views or through views integration?

drunken monkey’s picture

Yes, now that there's proper Views integration for saved searches, just create a view of saved searches with a Block display.

user654’s picture

.

drunken monkey’s picture

No. I don't think there's such a module yet.

zilla’s picture

have you looked at zeitgeist? it does some of this: https://drupal.org/project/zeitgeist

user654’s picture

.