これが他の人にとって大きな助けになることを願っています.PHPの学習にはしばらく時間がかかりました.
1 に答える
0
sphider の結果の横に画像を配置しようとしている方のために... 私は何千ものアイテムを含む製品フォルダーのインデックス作成に Sphider を使用しています。このスニペットで使用するファイル構造の例を次に示します。
www/
製品/
item1.php
item2.php
item3.php
画像/
item1.png
item2.png
item3.png
これを sphider/templates/standard/search_results.html (または sphider/templates/dark/search_results.html) の 75 行目の " class="title"> の直後に挿入します。
<?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;" />
基本的に、Sphider インデックスに 1234.php というページがある場合、これは画像 1234.png を見つけて、検索結果の横に表示しようとします。画像が見つからない場合は、デフォルトの画像 'ICS.png' (Image Coming Soon) が表示されます。
ハッピーコーディング
于 2013-02-19T05:32:31.450 に答える