有谁能告诉我为什么我的代码出错? 错误是:
PHP Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/home/bruce/public_html/shows_rc2/includes/template/theme/basic/theme.tpl" on line 143 "{plugin->showArtists}" unallowed methode "showArtists" in registered object "plugin" <-- \n thrown in /home/bruce/public_html/shows_rc2/includes/libs/smarty3/sysplugins/smarty_internal_templatecompilerbase.php on line 143
<?php
class plugin_smarty_artists extends baseplugin {
public $plugin_info = 'Smarty artists plugin';
/**
* description - A full description of your plugin.
*/
public $plugin_description = 'This plugin shows random artists.';
/**
* version - Your plugin's version string. Required value.
*/
public $plugin_myversion = '0.0.1';
/**
* requires - An array of key/value pairs of basename/version plugin dependencies.
* Prefixing a version with '<' will allow your plugin to specify a maximum version (non-inclusive) for a dependency.
*/
public $plugin_requires = null;
/**
* author - Your name, or an array of names.
*/
public $plugin_author = 'wmmw';
/**
* contact - An email address where you can be contacted.
*/
public $plugin_email = '';
/**
* url - A web address for your plugin.
*/
public $plugin_url = 'http://www.wm-mw.org';
public $plugin_actions = array ('install','uninstall','smarty');
function smartyFunctionshowArtists($params, $smarty) {
//path to directory to scan.
$directory = "/home/bruce/public_html/gallery/cr/boimages/";
//get all image files with a .jpg extension.
$images = glob("" . $directory . "*.jpg");
$imgs = '';
// create array
foreach($images as $image){ $imgs[] = "$image"; }
//shuffle array
shuffle($imgs);
//select first 20 images in randomized array
$imgs = array_slice($imgs, 0, 6);
//display images
foreach ($imgs as $img) {
echo "<img src='$img' /> ";
}
}
}
?>
&#13;
答案 0 :(得分:0)
我不熟悉插件语义的其余部分(也许你没有正确初始化插件?),但是不是应该用不同的命名约定声明的实际函数名?你正在使用camelCase(虽然showArtists中的s应该大写)。但聪明的功能期望被_下划线分开。所以我希望你的函数名是:smarty_function _showArtists