我一直在尝试加载五星模块并在外部php文件中显示所选节点的评分小部件。我已经获得了页面上显示的评级小部件,但它只显示小部件的降级版本(非JavaScript,下拉小部件和“费率”按钮)我查看了页面的源代码,但五星模块的JavaScript未加载。我曾尝试使用以下功能加载JavaScript,但没有运气:Drupal:在外部php文件中插入五星小部件
fivestar_add_js(); $ path = drupal_get_path('module','fivestar'); drupal_add_js($ path。'/ js/fivestar.js','inline','footer');
以下是PHP文件中的代码:
//require the bootstrap include
require_once 'includes/bootstrap.inc';
//Load Drupal
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
fivestar_add_css();
// I have used one of the following two functions one at a time to test.
fivestar_add_js();
$path = drupal_get_path('module','fivestar');
drupal_add_js($path.'/js/fivestar.js', 'inline', 'footer');
$book = $_GET["book"];
$chap = $_GET["chap"];
$prob = $_GET["prob"];
$string = $book.'/'.$chap.'/'.$prob;
$query = "SELECT ctcr.nid FROM content_type_comments_ratings AS ctcr WHERE ctcr.field_problem_value = '".$string."'";
$result=db_query($query);
$row = db_fetch_array($result);
if(isset($row['nid']))
{
$nid = $row['nid'];
node_load(FALSE, NULL, TRUE);
$fivestar = node_load($nid, NULL, TRUE);
if (function_exists('fivestar_widget_form')) print fivestar_widget_form($fivestar);
}
如果你可以给我一个提示或直接我在网络上一些阅读,我将不胜感激。非常感谢你提前。