doublespark/contao-search-screenshot

为Contao搜索结果添加页面预览截图

v1.0.8 2021-05-21 09:40 UTC

This package is auto-updated.

Last update: 2024-09-21 16:30:51 UTC


README

此模块将页面预览截图添加到搜索结果中。

PhantomJS

为了捕获截图,需要安装PhantomJS。

为了自动化安装PhantomJS,您可以使用包jakoch/phantomjs-installer。安装后,将PhantomInstaller\\Installer::installPhantomJS添加到项目的composer.json的post install和update命令中

"scripts": {
    "post-install-cmd": [          
        "PhantomInstaller\\Installer::installPhantomJS"
    ],
    "post-update-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ]
}

现在当您运行composer install时,PhantomJS将自动安装到/vendor/bin/phantomjs

如果您希望使用自定义的PhantomJS实例,可以从https://phantomjs.org/下载。如果您这样做,可能需要在设置中为PhantomJS设置一个自定义路径。

用法

生成截图

为了生成截图,必须设置一个服务器cron作业,每分钟运行以下命令

vendor/bin/contao-console search-screenshot:generate

如果您不想等待,您可以手动从CMS后端系统 > 搜索截图处触发所有页面的截图生成。

截图将自动每7天更新一次。

在结果中显示截图

该模块在搜索结果模板中提供了一个新的变量$this->screenshot。如果存在,该变量将持有截图的URL;如果不存在,则为空。

包括截图的模板已包含在内,可以在配置搜索模块时选择。选择使用search_with_screenshot.html5作为搜索模板。

配置

在系统 > 设置下,您将在“搜索截图配置”部分找到模块的一些配置选项。