Answer the question
In order to leave comments, you need to log in
How to display "Fivestar" module in custom tpl.php for taxonomy?
Hello!
There is a site on Drupal 7, there was a need to add a rating to the pages, which are taxonomy terms. Installed the Fivestar module, set it up, now you need to bring it to the frontend.
The developer created a separate template for the term pages. I'm trying to display a module in it, I found an example code for this:
<?php
$settings = array(
'content_type' => 'profile2',
'content_id' => $profileView->pid,
'entity' => $profileView,
'stars' => 5,
'field_name' => 'field_profile_rating',
'autosubmit' => TRUE,
'allow_clear' => FALSE,
'langcode' => 'und',
'text' => 'none', // options are none, average, smart, user, and dual
'tag' => 'vote',
'style' => 'average', // options are average, dual, smart, user
'widget' => array( 'name' => 'oxygen', 'css' => drupal_get_path('module', 'fivestar') . '/widgets/oxygen/oxygen.css' )
);
print render(drupal_get_form('fivestar_custom_widget', $profileView->field_profile_rating['und'][0], $settings));
?>
<?php
$term = taxonomy_term_load(arg(2));
$settings = array(
'content_type' => 'taxonomy_term', // Видимо, тип материала. Для таксономий такое понятие существует?
'content_id' => arg(2), // arg(2) достаточно для передачи id материала?
'entity' => $term, // Что сюда нужно передавать? В примере указан объект.
'stars' => 5,
'field_name' => 'field_rating_term',
'autosubmit' => TRUE,
'allow_clear' => FALSE,
'langcode' => 'und',
'text' => 'average', // options are none, average, smart, user, and dual
'tag' => 'vote',
'style' => 'average', // options are average, dual, smart, user
'widget' => array( 'name' => 'basic', 'css' => drupal_get_path('module', 'fivestar') . '/widgets/basic/basic.css' )
);
print render(drupal_get_form('fivestar_custom_widget', $term->field_rating_term['und'][0], $settings));
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question