I want the user to have access the hierarchical select I have now successfully built using the taxonomy. It displays in the form when building taxonomy.

How can I have that same hierarchical select display in a static page not in edit mode - anonymous users will use it as an informational tool.

I have tried copying the embedded code and .js and .css files into the contents->body field without success.

Many thanks.

Comments

webdev2’s picture

I have also added the following to the body field with PHP filter:

 if ($taxonomy):
    $vid = 2;                          // Vocabulary ID. CHANGE THIS!
    $config['module'] = 'hs_taxonomy'; // Set the module.
    $config['params']['vid'] = $vid;   // Set the parameters.
    $config['save_lineage'] = 1;       // save_lineage setting is enabled. CHANGE THIS!
  
print theme('hierarchical_select_selection_as_lineages', $node->taxonomy, $config);

endif;

It displays nothing when saved. Interestingly enough, in the page form (in edit mode) the taxonomy menu does appear correctly. All I want is for it to appear on the page after editing - when the page is saved and an anonymous user views it.

Thanks.

wim leers’s picture

Assigned: Unassigned » wim leers
Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

1) Do you want to display the lineages or the Hierarchical Select form item?
2) Is the vocabulary id of your vocabulary really 2?

webdev2’s picture

- I'm not sure sure what the difference between lineages or the Hierarchical Select form item.
- I put #2 because when I click to edit the vocabulary I want to use, the link is /admin/content/taxonomy/edit/vocabulary/2

Not knowing the difference between lineages and the Hierarchical Select form item, here's what I want:
when an anonymous user comes to a page I created, they see something very similar to what is on your demo page:
http://wimleers.com/demo/hierarchical-select/taxonomy

except, of course, my taxonomy.

Thanks.

wim leers’s picture

Status: Postponed (maintainer needs more info) » Fixed
StatusFileSize
new27.1 KB

That is in fact a form, just without a save button. Are you sure you don't want to present saved taxonomy data as in the attached screenshot (that's "displaying the lineages")?

If you really want to show a Hierarchical Select form item to allow users to browse the hierarchy, simply build a form without a submit function. You should be able to find out how to do that on your own.

webdev2’s picture

Many thanks for your time to answer my questions.

I understand now that page was a form without a save button - how do you do that?

The taxonomy is root + 1 deep. The user needs to be able to select the first and see the results of the that selection in the second select box. That's all the user needs. They will not make changes to anything. I just need it to display LIKE it would in a form.

Does that make sense? Thanks.

wim leers’s picture

Look at API.txt for an example on how to create a HS form item. You'll have to learn yourself how to use the Forms API.

webdev2’s picture

Thanks for your help. I see it's usefulness for projects. I don't think it would make sense on mine now. Thanks again.

Status: Fixed » Closed (fixed)

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

ranavaibhav’s picture

Version: 6.x-3.x-dev » 6.x-3.6
Assigned: wim leers » Unassigned
Status: Closed (fixed) » Active

using above code, i can see the linage printed, but they are just labels. Is there a way to link labels to it's term page?
i get following without links:

Parent Term > Level 1
Parent Term2 > Level 1 > Level 2

etc

wim leers’s picture

Assigned: Unassigned » wim leers
Status: Active » Fixed

Override the theme function (theme_hierarchical_select_selection_as_lineages()) to achieve that.

ranavaibhav’s picture

StatusFileSize
new1.93 KB

Thanks Wim for the quick response. However could you please give me some hints? I added the function in my theme template.php but have no idea what to modify. Sorry i don't know much about php. If my request is too specific, please feel free to close the issue. Thanks.

function danland_hierarchical_select_selection_as_lineages($selection, $config) {
  $output = '';

  $selection = (!is_array($selection)) ? array($selection) : $selection;

  // Generate a dropbox out of the selection. This will automatically
  // calculate all lineages for us.
  $selection = array_keys($selection);
  $dropbox = _hierarchical_select_dropbox_generate($config, $selection);

  // Actual formatting.
  foreach ($dropbox->lineages as $id => $lineage) {
    if ($id > 0) {
      $output .= '<br />';
    }

    $items = array();
    foreach ($lineage as $level => $item) {
      $items[] = $item['label'];
    }
    $output .= implode('<span class="hierarchical-select-item-separator">&#62;</span>', $items);
  }

  // Add the CSS.
  drupal_add_css(drupal_get_path('module', 'hierarchical_select') .'/hierarchical_select.css');

  return $output;
}
ranavaibhav’s picture

Status: Fixed » Active

woops!forgot to change the status.

wim leers’s picture

Status: Active » Fixed

If you don't know much PHP, you should learn it. It's not ethical to expect other people to do your work for you.

ranavaibhav’s picture

Thanks for your reply. I was not expecting you to do work for me. I was just seeking your HELP or HINT. But thanks anyway.

wim leers’s picture

I gave you sufficient hints. It's not sufficient for you because your knowledge level is not yet high enough. Just learn, try and you'll get there! :)

Status: Fixed » Closed (fixed)

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