我有一个tpl.php文件此代码为什么我在这里得到未定义的变量错误?
<?php foreach ($images as $image): ?>
<?php print $image ."\n"; ?>
<?php endforeach; ?>
我已中的预处理功能
function preprocess(&$vars) {
// Initialize our $images array.
$vars['images'] = array();
foreach ($vars['rows'] as $item) {
if (preg_match('@(<a.*?img.*?</a>)@i', $item, $matches)) {
$image = $matches[1];
}
elseif (preg_match('@(<\s*img\s+[^>]*>)@i', $item, $matches)) {
$image = $matches[1];
}
else {$images = NULL;}
// Add the image to our image array
$vars['images'][] = $image;
}
未定义可变以下:在此行中的预处理功能图像
$vars['images'][] = $image;
我的错误我编辑了上面的代码。我没有在原始文章中包含图片声明。 – dimmech