Exclude certain category from exposed view

Liliplanet - February 5, 2008 - 08:40

Hi!

I've seen this somewhere, but just cannot find it again. Please, how can I exclude certain categories from my exposed views dropdown?

The reason is that I have child categories in the dropdown which makes it sooo lo-n-g and would to keep only the parents.

Look forward to any response and thank you.
Lilian

...

mooffie - February 6, 2008 - 14:26

(Seen you post at http://groups.drupal.org/node/8665
Can't answer there because their newfangled 'preview' doens't work, so I answer here.)

I've seen the template hack at http://drupal.org/node/173555, but that excludes a content type

The items of the dropdown are stored in #options. That page you linked to showed you that you can modify these #options.

In your case you can completely re-populate #options with new items:

$options = ..prepare new items...;

$form[...somewhere...]['#options'] = $options;

Or, more concretely:

// our vocabulary ID:
$vid = 456;

// get the top-most terms:
$terms = taxonomy_get_tree($vid, 0, -1, 1);

// populate $options:
$options = array();
foreach ($terms as $term) {
  $options[$term->tid] = $term->name;
}
$options = array('**ALL**' => t('<All>')) + $options;

// stick it into the form:
$form['filter0']['#options'] = $options;

(haven't actually tried the code; I may have typos.)

Thank you so much for your

Liliplanet - February 6, 2008 - 14:42

Thank you so much for your reply Mooffie ..

Oops, a bit of a newbie here. Where do I put the code, in the arguments for the view?

and in

// our vocabulary ID:
$vid = 456;

// get the top-most terms:
$terms = taxonomy_get_tree($vid, 0, -1, 1);

// populate $options:
$options = array();
foreach ($terms as $term) {
  $options[$term->tid] = $term->name;
}
$options = array('**ALL**' => t('<All>')) + $options;

// stick it into the form:
$form['filter0']['#options'] = $<b>options</b>;?>

do I fill in options with the different options I do not want in the dropdown?

Most most appreciate your help.
Lilian

...

mooffie - February 6, 2008 - 16:21

a bit of a newbie here

So let's instead start with something simpler. Let's change the dropdown to show only South Africa and Japan. (if it works for you we can easily change it to use the more sofisticated code I typed above.)

Where do I put the code

We are writing a function that themes the filter form. This is a themeing function. A natural place for it is in your 'template.php' file, which is in your theme folder. (No, don't paste it into the 'Argument handling code'.)

Here's the function:

function theme_views_display_filters_directory_admin($view) {

  $form = drupal_retrieve_form('views_filters', $view);

  $options = array(
    '**ALL**' => '<All>',
    2 => 'South Africa',
    107 => 'Japan',
  );   

  $form['filter0']['#options'] = $options;

  $result = drupal_process_form('views_filters', $form);
  $output = drupal_render_form('views_filters', $form);
  return $output;
}

Paste it into your 'template.php'.

Note that the name of the function contains 'directory_admin'. That's the name of
your view and that's how Views knows to connect this specific function with your specific view.

This function builds a simple $options array, with the two countries, and sticks it in the form.

Does it work for you?

Mooffie, that is absolutely

Liliplanet - February 6, 2008 - 16:54

Mooffie, that is absolutely fantastic! Thank you so much! Beautiful!

1. Just to push the envelope a little, is it possible at all that drop-downs only have options that are only available if there is content attached to it?

ie there is no-one from Japan, so don't show Japan in the dropdown? If possible, it would be amazing for the directory drop-down.

2. Please Mooffie, also would it be possible to have the amounts (number) of 'content' per option also show next to each country? ie Japan 34

I'm so happy ;) thank you.

...

mooffie - February 6, 2008 - 17:45

is it possible at all that drop-downs only have options that are only available if there is content attached to it? [...] would it be possible to have the amounts (number) [...]

Yes.

You now have the following 5 lines:

  $options = array(
    '**ALL**' => '<All>',
    2 => 'South Africa',
    107 => 'Japan',
  );

Replace them with:

  $vid = 1; // CHANGE THIS number to match the vocabulary ID of your countries.

  // get all the terms:
  $terms = taxonomy_get_tree($vid);

  // count nodes per term
  $res = db_query("SELECT tid, COUNT(nid) AS count FROM {term_node} GROUP BY tid");
  while ($o = db_fetch_object($res)) {
    $count[$o->tid] = $o->count;
  }

  // populate $options:
  $options = array('**ALL**' => t('<All>'));
  foreach ($terms as $term) {
    if (!empty($count[$term->tid])) {
      $options[$term->tid] = str_repeat('--', $term->depth) . $term->name .' ('. $count[$term->tid] .')';
    }
  }

BUT,

Note the first line. The $vid = 1; You must change this '1' to match the vocabulary ID of your countries vocabulary. Every vocabulary has a numeric ID. If you don't know how to find it, change that '1' to '2', then to '3', then to '4', till things work....

You are singularly an

Liliplanet - February 6, 2008 - 17:48

You are singularly an absolute genius! WOW, that is so fantastic and has made a huge difference to my new site.

I cannot thank you enough for your time and wish you a perfect day!

Thank you so much Mooffie!

Mooffie, oops .. just a

Liliplanet - February 6, 2008 - 17:55

Mooffie, oops .. just a quick question ..

I would like to do this for categories 1 and 2.

So countries (1) and the other seperate exposed view dropdown directory (2) on the same page.

Tried 1,2 , but uhmm no go.

Learning so much here and thank you Mooffie.

Lilian

...

mooffie - February 6, 2008 - 18:53

I would like to do this for categories 1 and 2.

All that's needed is to move some code into a separate function so it can be re-used.

Here's the new code, to replace all you have:

/**
* Get items for use in a taxonomy dropdown. Tree structure is shown,
* as well as count of nodes in brackets. Terms not associated with
* nodes are skipped.
*/
function get_fancy_vocabulary_dropdown($vid) {

  // count nodes per term:
  static $count = NULL;
  if (!isset($count)) {
    $count = array();
    $res = db_query("SELECT tid, COUNT(nid) AS count FROM {term_node} GROUP BY tid");
    while ($o = db_fetch_object($res)) {
      $count[$o->tid] = $o->count;
    }
  }

  // get the terms:
  $terms = taxonomy_get_tree($vid);

  // populate $options:
  $options = array('**ALL**' => t('<All>'));
  foreach ($terms as $term) {
    if (!empty($count[$term->tid])) {
      $options[$term->tid] = str_repeat('-', $term->depth) . $term->name .' ('. $count[$term->tid] .')';
    }
  }
 
  return $options;
}

/**
* Spice up our 'directory_admin' view with fancier taxonomy dropdowns.
*/
function theme_views_display_filters_directory_admin($view) {
  $form = drupal_retrieve_form('views_filters', $view);

  $countries_vid = 1; // CHANGE THIS number to match the vocabulary ID of your countries.
  $directories_vid = 2; // CHANGE THIS number to match the vocabulary ID of your directories.

  $form['filter0']['#options'] = get_fancy_vocabulary_dropdown($countries_vid);
  $form['filter1']['#options'] = get_fancy_vocabulary_dropdown($directories_vid);
 
  $result = drupal_process_form('views_filters', $form);
  $output = drupal_render_form('views_filters', $form);
  return $output;
}

As usual, note the hardcoded '1' and '2' vocabulary IDs. You may need to change them to suit your case.

(no, I'm no genius, I just did some homework. I hope your success with this code encourages you to experiment and learn more about Drupal ;-)

It's gorgeous Mooffie, thank

Liliplanet - February 7, 2008 - 11:46

It's gorgeous Mooffie, thank you so much!

Wishing you a fabulous day ...

Mooffie, you have been so

Liliplanet - February 7, 2008 - 12:40

Mooffie, you have been so kind, but perhaps you could send me in the right direction please ..

The dropdowns are fantastic, but I notice that if you select a country, say Japan, the directory listings still shows all the listings (from all countries) before you submit the search and then probably no results.

Is there any way possible that when you select ie Japan, the directory updates via ajax or javascript to show only those in Japan before you do the submit?

Have all the jquery modules installed.

Look forward to any reply.
Lilian

...

mooffie - February 7, 2008 - 18:09

[...] and then probably no results.

BTW, you should configure your view to print a nice message when no results are found. There's an 'Empy Text' box.

Is there any way possible that [...]

Don't ask is-it-possible questions. Everything is possible.

the directory updates via ajax

AJAX is possible, but not very feasible, I'll have to instruct you in the building of a module.

However, there's one more possibility besides AJAX: to refresh the page, completely, when a user changes the country. That's a compromise, but it's quite easy to implement.

Here's the new code, to replace all you have.

It has two enhancement:
1. When a user changes country, page refreshes.
2. The 'directory' dropdown options are restricted to the country selected.

/**
* Get items for use in a taxonomy dropdown. Tree structure is shown,
* as well as count of nodes in brackets. Terms not associated with
* nodes are skipped.
*
* @param $vid
*   The vocabulary ID
* @param $domain
*   Optional. If non-zero, restrict display to nodes tagged by this tid.
* @param $includes
*   Optional. An array of tid's to always include in display.
*/
function get_fancy_vocabulary_dropdown($vid, $domain = 0, $includes = array()) {

  // count nodes per term:
  static $count = array();
  if (!isset($count[$domain])) {
    $count[$domain] = array();
    if (!$domain) {
      $sql = "SELECT COUNT(nid) AS count, tid FROM {term_node} GROUP BY tid";
    }
    else {
      // restrict counting to nodes tagged with the $domain tid.
      $sql = "
        SELECT
          COUNT(n.nid) AS count, tn.tid
        FROM
          {term_node} n
        INNER JOIN
          {term_node} tn ON n.nid = tn.nid
        WHERE
          n.tid = $domain
        GROUP BY
          tn.tid";
    }
    $res = db_query($sql);
    while ($o = db_fetch_object($res)) {
      $count[$domain][$o->tid] = $o->count;
    }
  }

  // get the terms:
  $terms = taxonomy_get_tree($vid);

  // populate $options:
  $options = array('**ALL**' => t('<All>'));
  foreach ($terms as $term) {
    if (!empty($count[$domain][$term->tid]) || in_array($term->tid, $includes)) {
      $options[$term->tid] = str_repeat('--', $term->depth) . $term->name .
                ' ('. intval($count[$domain][$term->tid]) .')';
    }
  }
 
  return $options;
}

/**
* Spice up our 'directory_admin' view with fancier taxonomy dropdowns.
*/
function theme_views_display_filters_directory_admin($view) {

  $country   = isset($_GET['filter0']) ? intval($_GET['filter0']) : 0;
  $directory = isset($_GET['filter1']) ? intval($_GET['filter1']) : 0;

  $form = drupal_retrieve_form('views_filters', $view);

  $countries_vid = 1; // CHANGE THIS number to match the vocabulary ID of your countries.
  $directories_vid = 2; // CHANGE THIS number to match the vocabulary ID of your directories.

  $form['filter0']['#options'] = get_fancy_vocabulary_dropdown($countries_vid);
  $form['filter1']['#options'] = get_fancy_vocabulary_dropdown($directories_vid, $country, array($directory));

  $js =<<<EOS
$(function() {
  // When user changes country, refresh the page.
  $('.view-directory-admin select[@name=filter0]').change(function() {
    // but first hide the controls...
    $(':input', this.form).not(this).css('visibility', 'hidden');
    // ...and show a message:
    $(':input[@name=filter1]', this.form).before("<span style='position: absolute'>Wait...</span>");
    // submit!
    this.form.submit();
  });
});
EOS;
  drupal_add_js($js, 'inline');

  $result = drupal_process_form('views_filters', $form);
  $output = drupal_render_form('views_filters', $form);
  return $output;
}

...

mooffie - February 7, 2008 - 18:43

Maybe it'd be better to make _all_ the dropdowns refresh the page, and hide the 'submit' button?

I think then the interface would be easier to undertand. All dropdowns will behave the same.

It's easy to do this, but the downside is that if I want to see all 'Script Writes' in 'England' I'll have to suffer two page refreshes.

...

mooffie - February 7, 2008 - 18:47

[...] it'd be better to make _all_ the dropdowns refresh the page,

that, plus making the 'directory' dropdown show _all_ the options; "(0)" will be displayed if no nodes exist. What do you think?

Hi Mooffie, Yes it works

Liliplanet - February 8, 2008 - 10:18

Hi Mooffie,

Yes it works wonderfully, and it is a bit disturbing to have the page refresh completely, but it is the lesser of 2 evils .. (not having a 'no results' page).

Mooffie, just maybe ... that only the dropdown's refresh? Maybe in a panel or that the dropdown's are seperate to the page somehow? I honestly cannot imagine how that can be done.

You are so kind and most appreciate your help Mooffie. As the directory will be the driving force behind the new site it would amazing that it is streamlined without the full page refresh, but if not, I am super-happy.

Look forward to hearing from you.
Lilian

...

mooffie - February 8, 2008 - 14:36

Next week I'll look into some existing modules that purport to AJAXify things, maybe you can use one of those.

(Writing a mini module of our own tailored to our needs is an easy solution, but isn't always a wise one.)

...

mooffie - February 11, 2008 - 12:59

OK, I decided to save time and pick the 'easy' solution.

I moved the code into a module. Download the three files:

planet.module
planet.js
planet.info

Drop them into some folder and enable this module. BUT you must first remove the previous code, from 'template.php', or else you'll see nasty error messages.

(I named the module 'planet' because I had the impression the site's name is 'film planet'.)

If, for some reason, it doesn't work, don't disable it but let me see it.

Mooffie, thank you so much!

Liliplanet - February 11, 2008 - 18:53

Mooffie, thank you so much! I have not tried it yet, as I'm now changing my server and as soon as that is done ...

Have a wonderful week ;)
Lilina

Dear Mooffie, Hope you've

Liliplanet - February 16, 2008 - 16:22

Dear Mooffie,

Hope you've been very well. Mooffie, I'm moved my site to http://www.ufilm.tv and rebuilt from the start (just think the .co.za domain is not international?)

I've now implemented your wonderful Planet.module, but think it does not call for ajax somewhere. Am I perhaps missing the ajax in the zen-classic theme folder?

Current planet.module code is:

<?php
// $Id$

/**
* @file
* Customizations for the Filmmaker website.
*/

function planet_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    $items[] = array(
      'path'     => 'ajax/filters',
      'callback' => 'planet_ajax_filters',
      'type'     => MENU_CALLBACK,
      'access'   => TRUE,
    );
  }
  return $items;
}

/**
* Returns an exposed filters form, for a view. Used by javascript.
*/
function planet_ajax_filters($view_name = 'directory') {
  $view = views_get_view($view_name);
  if (!$view) {
    print drupal_to_js(array('status' => FALSE, 'data' => "View '$view_name' not found"));
  } else {
    $form = views_theme('views_display_filters', $view);
    print drupal_to_js(array('status' => TRUE, 'data' => $form));
  }
  exit();
}

/**
* Get items for use in a taxonomy dropdown. Tree structure is shown,
* as well as count of nodes in brackets. Terms not associated with
* nodes are skipped.
*
* @param $vid
*   The vocabulary ID
* @param $domain
*   Optional. If non-zero, restrict display to nodes tagged by this tid.
* @param $includes
*   Optional. An array of tid's to always include in display.
*/
function get_fancy_vocabulary_dropdown($vid, $domain = 0, $includes = array()) {

  // count nodes per term:
  static $count = array();
  if (!isset($count[$domain])) {
    $count[$domain] = array();
    if (!$domain) {
      $sql = "SELECT COUNT(nid) AS count, tid FROM {term_node} GROUP BY tid";
    }
    else {
      // restrict counting to nodes tagged with the $domain tid.
      $sql = "
        SELECT
          COUNT(n.nid) AS count, tn.tid
        FROM
          {term_node} n
        INNER JOIN
          {term_node} tn ON n.nid = tn.nid
        WHERE
          n.tid = $domain
        GROUP BY
          tn.tid";
    }
    $res = db_query($sql);
    while ($o = db_fetch_object($res)) {
      $count[$domain][$o->tid] = $o->count;
    }
  }

  // get the terms:
  $terms = taxonomy_get_tree($vid);

  // populate $options:
  $options = array();
  foreach ($terms as $term) {
    if (!empty($count[$domain][$term->tid]) || in_array($term->tid, $includes)) {
      $options[$term->tid] = str_repeat('--', $term->depth) . $term->name .
' ('. intval($count[$domain][$term->tid]) .')';
    }
  }
 
  return $options;
}

/**
* Spice up our 'directory' view with fancier taxonomy dropdowns.
*/
function theme_views_display_filters_directory($view) {

  drupal_add_js(array('planet' => array('filters_url' => url('ajax/filters', NULL, NULL, TRUE))), 'setting');
  drupal_add_js(drupal_get_path('module', 'planet') .'/planet.js', 'module', 'header', FALSE, FALSE);

  $country   = isset($_GET['filter0']) ? intval($_GET['filter0']) : 0;
  $directory = isset($_GET['filter1']) ? intval($_GET['filter1']) : 0;

  $form = drupal_retrieve_form('views_filters', $view);

  $countries_vid   = 2; // CHANGE THIS NUMBER to match the vocabulary ID of your countries.
  $directory_vid = 1; // CHANGE THIS NUMBER to match the vocabulary ID of your directories.

  $form['filter0']['#options'] = array('**ALL**' => t('<All>')) +
                                  get_fancy_vocabulary_dropdown($countries_vid);
  $form['filter1']['#options'] = array('**ALL**' => t('<All>')) +   
                                  get_fancy_vocabulary_dropdown($directory_vid, $country, array($directory));

  $result = drupal_process_form('views_filters', $form);
  $output = drupal_render_form('views_filters', $form);
  return $output;
}

I'm so happy Mooffie, thank you so much!

Look forward to hearing from you.
Lilian

...

mooffie - February 17, 2008 - 10:26

Hi,

moved my site to http://www.ufilm.tv and [...]

But we should keep referring to the old URL, right?

I see two problems:

1. You didn't enable the 'planet' module. You should, preferably, drop its three files in the 'sites/all/modules' folder, then go to Drupal's modules page and enable the module.

2. You didn't undo the changes to 'template.php'. What we did in 'template.php', at the start of this discussion, isn't necessary anymore, because I moved all code to this new module. You should delete the two functions, theme_views_display_filters_directory_admin() and get_fancy_vocabulary_dropdown(), from your 'template.php'. In fact, unless you do this you won't be able to enable the 'planet' module, because PHP will complain that some function was defined twice.

/**
* Spice up our 'directory' view with fancier taxonomy dropdowns.
*/
function theme_views_display_filters_directory($view) {

You've changed the view's name from 'directory_admin' to 'directory'. That's absolutely fine. But note that there's one occurrence of 'directory_admin' in the 'planet.js' file and you should update it as well.

Thank you Mooffie for your

Liliplanet - February 17, 2008 - 10:52

Thank you Mooffie for your quick response. Mooffie, I've moved the whole site to the new http://www.ufilm.tv and will only be working on there. Filmmaker.co.za will be pointing to the new site at some stage.

Yes, you were right, changed the planet.js file and now it updates with .. one moment please .. but it does not load the information of that particular country.

planet.js

// $Id$

$(function() {

  /**
   * Ajaxify exposed filter forms on our page. It triggers form refresh
   * for some dropdown boxes.
   */
  function planet_setup_form() {

    /**
     * Refreshes the form. Fetches a new exposed filters form.
     */
    var refresh_form = function(form, view_name, wait_selector, wait_message) {
      var button = $('.form-submit', form)[0];
      Drupal.redirectFormButton(Drupal.settings.planet.filters_url+'/'+view_name, button, {
        onsubmit: function() {
          // display a 'wait' message...
          $(wait_selector, form)
            .css('visibility', 'hidden')
            .before("<span style='position: absolute'>"+wait_message+"</span>");
        },
        onerror: function (data) {
          if (data.length > 5) {
            $(form).before('<h2 class="error">Some error occured: '+data+'</h2>').remove();
          }
        },
        oncomplete: function (data) {
          // Prevent flicker: wrap the form, go up this wrapper, overwrite its content.
          $(form).wrap('<div></div>').parent().html(data);
          planet_setup_form();
        }
      });
      button.onfocus();
      button.click();
    }; // refresh_form()

    if (!jQuery.prototype.onechange) {
      alert('Wrong version of jQuery');
      return;
    }
    $('.view-directory select[@name=filter0]').onechange(function() {
      refresh_form(this.form, 'directory', 'select[@name=filter1]', 'one moment please .. loading data');
    });
  } // planet_setup_form()

  planet_setup_form();

});

and planet.module

<?php
// $Id$

/**
* @file
* Customizations for the Filmmaker website.
*/

function planet_menu($may_cache) {
  $items = array();
  if (!$may_cache) {
    $items[] = array(
      'path'     => 'ajax/filters',
      'callback' => 'planet_ajax_filters',
      'type'     => MENU_CALLBACK,
      'access'   => TRUE,
    );
  }
  return $items;
}

/**
* Returns an exposed filters form, for a view. Used by javascript.
*/
function planet_ajax_filters($view_name = 'directory') {
  $view = views_get_view($view_name);
  if (!$view) {
    print drupal_to_js(array('status' => FALSE, 'data' => "View '$view_name' not found"));
  } else {
    $form = views_theme('views_display_filters', $view);
    print drupal_to_js(array('status' => TRUE, 'data' => $form));
  }
  exit();
}

/**
* Get items for use in a taxonomy dropdown. Tree structure is shown,
* as well as count of nodes in brackets. Terms not associated with
* nodes are skipped.
*
* @param $vid
*   The vocabulary ID
* @param $domain
*   Optional. If non-zero, restrict display to nodes tagged by this tid.
* @param $includes
*   Optional. An array of tid's to always include in display.
*/
function get_fancy_vocabulary_dropdown($vid, $domain = 0, $includes = array()) {

  // count nodes per term:
  static $count = array();
  if (!isset($count[$domain])) {
    $count[$domain] = array();
    if (!$domain) {
      $sql = "SELECT COUNT(nid) AS count, tid FROM {term_node} GROUP BY tid";
    }
    else {
      // restrict counting to nodes tagged with the $domain tid.
      $sql = "
        SELECT
          COUNT(n.nid) AS count, tn.tid
        FROM
          {term_node} n
        INNER JOIN
          {term_node} tn ON n.nid = tn.nid
        WHERE
          n.tid = $domain
        GROUP BY
          tn.tid";
    }
    $res = db_query($sql);
    while ($o = db_fetch_object($res)) {
      $count[$domain][$o->tid] = $o->count;
    }
  }

  // get the terms:
  $terms = taxonomy_get_tree($vid);

  // populate $options:
  $options = array();
  foreach ($terms as $term) {
    if (!empty($count[$domain][$term->tid]) || in_array($term->tid, $includes)) {
      $options[$term->tid] = str_repeat('--', $term->depth) . $term->name .
' ('. intval($count[$domain][$term->tid]) .')';
    }
  }
 
  return $options;
}

/**
* Spice up our 'directory' view with fancier taxonomy dropdowns.
*/
function theme_views_display_filters_directory($view) {

  drupal_add_js(array('planet' => array('filters_url' => url('ajax/filters', NULL, NULL, TRUE))), 'setting');
  drupal_add_js(drupal_get_path('module', 'planet') .'/planet.js', 'module', 'header', FALSE, FALSE);

  $country   = isset($_GET['filter0']) ? intval($_GET['filter0']) : 0;
  $directory = isset($_GET['filter1']) ? intval($_GET['filter1']) : 0;

  $form = drupal_retrieve_form('views_filters', $view);

  $countries_vid   = 2; // CHANGE THIS NUMBER to match the vocabulary ID of your countries.
  $directory_vid = 1; // CHANGE THIS NUMBER to match the vocabulary ID of your directories.

  $form['filter0']['#options'] = array('**ALL**' => t('<All>')) +
                                  get_fancy_vocabulary_dropdown($countries_vid);
  $form['filter1']['#options'] = array('**ALL**' => t('<All>')) +   
                                  get_fancy_vocabulary_dropdown($directory_vid, $countries, array($directory));

  $result = drupal_process_form('views_filters', $form);
  $output = drupal_render_form('views_filters', $form);
  return $output;
}

So much appreciate your kind help Mooffie, it's wonderful.

Just one quick question. When I want to also load an extra ajax for taxonomy/term ... is it easy to do?

Wishing you a fabulous day.
Lilian

...

mooffie - February 17, 2008 - 12:49

Yes, you were right, changed the planet.js file and now it updates with ..

No.

What you see now, here, is the old code. It's the stage we were at before I made the new module. What you see here isn't AJAX: the whole page is refreshed.

The 'planet' module isn't even enabled.

Do you remember that we put some code in 'template.php'? Now you need to undo that. You need to remove the code that we inserted there. In other words, you need to restore things to the state they were on February 5. Let's call this "step 1". Then, and only then, you can continue to "step 2", which is the installation of the 'planet' module.

(How do I know you're using the old code? ...I do 'View Source' in my browser and see the old Javascript chunk.)

Thank you Mooffie for your

Liliplanet - February 17, 2008 - 12:56

Thank you Mooffie for your reply. Mooffie, I'm not using that installation anymore, my site is now at http://www.ufilm.tv

The directory is the front page when you access that site. That directory on ufilm.tv has the planet.module installed.

If you have a problem seeing some pages, I did a test with cloaking the domain name and now put it back. It might take a couple of minutes to propagate again. You are in the States (I think) so it should be good there by now.

Thank you so much for your help.
Lilian

...

mooffie - February 17, 2008 - 14:20

drupal_set_header('Content-Type: text/javascript; charset=utf-8');

No, I see that this line didn't solve the problem. Please remove that line so I can check things further.

(The browser thinks there's a '<pre>' tag enveloping that red code, that's why it can't parse it.)

...

mooffie - February 17, 2008 - 16:00

OK, we got rid of that red abomination :-)

Now,

the only problem left is that the 'directories' dropdown doesn't change. It always shows the same listing.

The problem is this:

  $form['filter1']['#options'] = array('**ALL**' => t('<All>')) +   
                                  get_fancy_vocabulary_dropdown($directory_vid, $countries, array($directory));

See the $countries? If should be $country. Singular, not plurals. It's an error you made when you edited that area.

Yes!! Stunning! Wow! You are

Liliplanet - February 17, 2008 - 16:44

Yes!! Stunning! Wow! You are a Super-Star and cannot thank you enough for this very kind input making this directory work.

Just re a previous question .. if it's not too much Mooffie please ..

When you click through to a taxonomy/term, somehow the dropdown's are normal without this fabulous js.

Is there a simple way to incorporate it into the script?

My apologies if this is becoming a nightmare, but we are so close ;)

Lilian

...

mooffie - February 17, 2008 - 17:26

When you click through to a taxonomy/term, somehow [...]

How did you put the filters on these taxonomy pages?

(You should hand me the latest planet.module and planet.js you use so I'll update my copy. But it won't be nice to pollute this thread anymore. Maybe you can upload them somewehere and provide a link.)

Thank you Mooffie, I've

Liliplanet - February 17, 2008 - 17:58

Thank you Mooffie, I've emailed you directly.

subscribing. this looks great

SocialNicheGuru - June 3, 2008 - 17:35

I am having problems with exposed filters for my interest vocabulary showing everything.

i have multiple filters ie. node type, author, etc.

one of them is the interest vocabulary. If I implement this override, it would override the other filters too correct?

Chrs

...

mooffie - June 3, 2008 - 17:54

When I first replied to Lily's original question I didn't know the extent to which she'd want to go.

Now that I know, I can say that the solution I gave here is a very poor one. It requires that you actively maintain the code.

A much, much better solution is to use the Faceted Search module.

checkbox

etcetera9 - May 20, 2009 - 14:57

Hey there,

If I understand correctly,

"Limit list to selected items
If checked, the only items presented to the user will be the ones selected here."

option on the views exposed menu limits the filter accordingly. By the way it is in the Views 6.x -2.5 version. I dont know if it exists in earlier versions...

Sinan

Dear Sinan, Thank you for

Liliplanet - May 20, 2009 - 16:00

Dear Sinan,

Thank you for your reply. Yes, it's a year later and now on Drupal 6.x :) I still have not figured it out.

On Views 2, have tried 'limit list to selected items', but that was not actually what I had in mind. I would like the dropdown to only show terms that have content attached to them. In this particular case it is 'country'.

So when there are nodes attached to ie United States and Italy, in the dropdown only show those 2 countries and not 'all'. Is not possible manually as content is submitted by over 12 000 users :)

Do you perhaps have a solution for this? Would most appreciate any assistance.

Lilian

Update: see: http://www.filmcontact.com/directory

I also find a problem, that once you have selected a country and it loads, you are not able to select another country as it searches within that vocabulary. Basically the exposed view only works on the first request.

Uh, I am sorry. I just

etcetera9 - May 21, 2009 - 09:38

Uh, I am sorry. I just replied by reading the first post, thinking it was something trivial.

I dont have any solution for you, sorry.

But the problem you mentioned on your last post doesnt happen to me. I can select another country and apply the filter again...

Sinan

Thank you again Sinan for

Liliplanet - May 21, 2009 - 10:42

Thank you again Sinan for your reply.

Sorry I meant, if you click on one of the taxonomy terms in the directory, and then when you select a country from the dropdown, it searches within the term you previously selected.

So then the exposed view does not work ..

Have you perhaps seen this before? Perhaps there is an argument I have wrong in the view?

Look forward to any reply.

Lilian

I think this is because when

etcetera9 - May 21, 2009 - 12:00

I think this is because when you click one of the taxonomy terms, it loads that taxonomy term page. For example when you click on Cape Town term, you go to Cape Town term page. Here, when you want to use filter, it chooses from the entries who are listed on that term page. It is a normal behavior, isnt it?

http://drupal.org/node/99370

In this entry, they talk about adding reset functionality to a filter. I dont know if it may be of use. But I think you have to somehow reset your view's url first, then apply filter...

Sorry if I cannot help you any further but I am not that experienced...

Sinan

for views 6.2.x: are the

momper - June 3, 2009 - 13:03

for views 6.2.x: are the functions mooffie used are still the same? or is there another way for the current views version?

thanks momper

Unfortunately, no, it does

Liliplanet - June 3, 2009 - 13:25

Unfortunately, no, it does not work in views 2 .. how I wish :)

It would be fabulous as a module as I've never been able to sort out this specific issue in drupal 6.x.

Exposed form to load taxonomy terms via js

Liliplanet - August 19, 2009 - 15:22

Just wishing out loud .. have searched, tried every possible way to change this planet.module to 6.x with not such good results.

I would be such a stunning way to easily find results in an exposed view by taxonomy term. It only loads terms that have results and then loads next taxo term related to the first query.

Then tried all other options ie. multi-select, faceted search, HS and more, and nothing comes close to this beautiful module.

Unfortunately it does not work in 6.x (:

Just maybe .. ?

 
 

Drupal is a registered trademark of Dries Buytaert.