Php 结果页面中带有产品图像的Sphider-Sphider 1.3.5
我希望这能对其他人有很大帮助,我花了一段时间学习PHP,但当我拼凑起来时,它给了我一个很好的PHP高潮。对于那些希望在sphider结果旁边放置图像的人。。。 我使用Sphider为包含数千项的产品文件夹编制索引,以下是我用于此代码段的文件结构示例: 万维网/ 产品/ item1.php item2.php item3.php 图像/ 项目1.png 项目2.png 项目3.png 将其插入第75行“class=”title“>Php 结果页面中带有产品图像的Sphider-Sphider 1.3.5,php,Php,我希望这能对其他人有很大帮助,我花了一段时间学习PHP,但当我拼凑起来时,它给了我一个很好的PHP高潮。对于那些希望在sphider结果旁边放置图像的人。。。 我使用Sphider为包含数千项的产品文件夹编制索引,以下是我用于此代码段的文件结构示例: 万维网/ 产品/ item1.php item2.php item3.php 图像/ 项目1.png 项目2.png 项目3.png 将其插入第75行“class=”title“> “alt=”“align=“left”style=“右边距:10
“alt=”“align=“left”style=“右边距:10px;边框:0;”/>
基本上,如果您的Sphider索引中有一个名为1234.php的页面,那么这将尝试查找图片1234.png,并将其放在搜索结果的旁边。如果找不到图像,它将显示默认图像“ICS.png”(图像即将发布)
快乐编码
<?PHP
// Edit here
$url_path = "http:// www.yoursite.com/product/"; // The url leading to your indexed pages.
$url_ext = ".php"; // The file extension of indexed pages.
$image_path = "../images/"; // Path to image folder.
$image_ext = ".png"; // The file extension of images.
// To here
$image = str_replace("$url_path", "$image_path", $url);
$image = str_replace("$url_ext", "$image_ext", $image);
if (file_exists($image)) {
// do nothing or Your Option
} else { $image = $image_path . "ICS" . $image_ext; } ?>
<img src="<?PHP print $image ?>" alt="" align="left" style="margin-right:10px; border:0;" />