3

我在我的网站中使用 Joomla 智能搜索,我想在搜索结果中显示文章的介绍图像和一些额外字段。

Joomla 智能搜索删除了任何 html 标签,我想防止这样做额外的字段

4

4 回答 4

2

www\plugins\finder\content打开content.php 然后搜索getListQuery,在->select list add ->select('a.images AS image'); 保存并关闭文件

在 www\components\com_finder\views\search\tmpl 打开default_result.php 然后在标签后搜索class="result-title添加这些行:

<?php $image=json_decode($this->result->image); ?>
<?php $aimage=$image->image_intro; ?>   
<div class="search-img">
<a href="<?php echo JRoute::_($route); ?>">
<img src="/<?php echo $aimage; ?>" >
</a>
</div>

保存并关闭

不要忘记清除重新索引智能搜索

于 2014-08-25T13:44:05.073 回答
1

智能搜索插件说明应该索引哪些字段。你可以用你自己的替换一些智能搜索插件。

于 2013-05-19T02:00:22.983 回答
0

我找到了一个解决方案,虽然不像我想要的那样,但它确实有效。该解决方案在搜索结果(图像、链接和您想要的所有内容)中显示文章的“阅读更多”内的介绍文本和所有内容。

这个解决方案在这里http://forum.joomla.org/viewtopic.php?p=2324152找到并且说是这样的:

“您需要使用http://docs.joomla.org/Understanding_Output_Overrides中描述的步骤为 components/com_finder/views/search /tmpl/default_result.php 布局文件创建布局覆盖创建布局后覆盖,你应该改变”

<?php echo JHtml::_('string.truncate', $this->result->description, $this->params->get('description_length', 255)); ?>

在布局文件中:

<?php echo $this->result->summary; ?>

位置应该是 templates/template_name/html/com_finder/search/default_result.php

于 2013-05-20T12:35:31.507 回答
0

实际上有一个非常简单的解决方案。K2 根据 id 的 md5 哈希保存图像。

添加这个:

<div class="search-img">
<img src="<?php echo JURI::base().'media/k2/items/cache/'.md5("Image".$this->result->id).'_M.jpg'; ?>" />
</div>

对 default_result.php 的 html 覆盖将显示相应的 k2 项(此处为中等分辨率)

于 2015-07-23T01:38:49.153 回答