zen cart多图实现解析

zen cart默认的获取产品多图的代码在includesmodulesadditional_images.php文件里面,主要的代码在

// Check for additional matching images
$file_extension = $products_image_extension;
$products_image_match_array = array();
if ($dir = @dir($products_image_directory)) {
while ($file = $dir->read()) {
if (!is_dir($products_image_directory . $file)) {
if (substr($file, strrpos($file, ‘.’)) == $file_extension) {
// if(preg_match(“/” . $products_image_match . “/i”, $file) == ’1′) {
if(preg_match(“/” . $products_image_base . “/i”, $file) == 1) {
if ($file != $products_image) {
if ($products_image_base . str_replace($products_image_base, ”, $file) == $file) {
// echo ‘I AM A MATCH ‘ . $file . ‘
’;
$images_array[] = $file;
} else {
// echo ‘I AM NOT A MATCH ‘ . $file . ‘
’;
}
}
}
}
}
}
if (sizeof($images_array)) {
sort($images_array);
}
$dir->close();
}
主要根据主图所在的位置目录下面,按主题的文件名来匹配,然后把所有的图片保存在$products_image_match_array数组里面。匹配规则:
“/” . $products_image_base . “/i”
zencart后台默认没有提供上传多图的功能,但是images handler插件提供了多图管理的功能。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: