Drupal:重用多面搜索块

发布于 2024-10-06 12:52:27 字数 410 浏览 3 评论 0原文

Drupal 中的分面搜索模块为每个新的分面搜索环境(当前搜索、引导搜索、相关搜索等)创建一组块。

如果您要为书籍等创建一个分面搜索环境,您可以使用基本路径浏览/书籍起始页来设置它作为浏览/书籍/结果。要显示分面搜索块,您可以将该块的页面特定可见性设置设置为“仅在列出的页面上显示”,并将实际页面设置为

browse/books
browse/books/results*

问题:我想重新使用不同登陆页面上的“引导搜索”块。登陆页面应显示可用搜索词的列表(sidebar-left)并显示页面其余部分的视图。

到目前为止,简单地向“仅在列出的页面上显示”列表中添加不同的路径没有效果。

The faceted search module in Drupal creates a set of blocks for each new faceted search environment (current search, guided search, related, etc).

If you were to create a faceted search environment for e.g. books, you could set it up with a base path browse/books and a start page as browse/books/results. To display the faceted search blocks, you'd then set the Page Specific Visibility settings for the block as 'Show on only the listed pages' and the actual pages as

browse/books
browse/books/results*

Question: I would like to re-use the 'guided search' block on a different landing page. The landing page should display a list of available search terms (sidebar-left) and show a view over the rest of the page.

So far, simply adding a different path to the list of 'show on only the listed pages' has no effect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

独留℉清风醉 2024-10-13 12:52:27

实现这一目标的一种方法是添加一个新的自定义块,然后尝试使用以下命令显示实际块:

<?php
   $block = module_invoke('faceted_search_ui', 'block', 'view', 'xxxxx');
   print $block['content'];
?>

其中 xxxxx 是分面搜索环境的 ID,例如 1_guided< /代码>。问题是,查看functionfaceted_search_ui_block(...)只能让你到目前为止。仅当环境处于正确状态时才会渲染该块,除非它是假定在关联路径下运行的已知分面搜索环境,否则情况并非如此。

所以,看起来不可能。

One way of almost getting there is to add a new custom block and then trying to display the actual block using the following:

<?php
   $block = module_invoke('faceted_search_ui', 'block', 'view', 'xxxxx');
   print $block['content'];
?>

Where xxxxx is the id of the faceted search environment, for example 1_guided. Problem is that looking at function faceted_search_ui_block(...) will only get you so far. The block will only be rendered if the environment is in the correct state, which, unless it is a known faceted search environment supposedly running under the associated path, it is not.

So, doesn't look like it is possible.

不奢求什么 2024-10-13 12:52:27

Drupal 老手可能能够提供更好、更干净、更正确的解决方案,但以下内容对我有用:

我添加了一个运行以下 PHP 的新块:

$env = faceted_search_env_load ( $fs_env_id );
if (!$env->ready()) 
{
    $env->prepare();
    $env->execute();
}
faceted_search_ui_add_css();
$env->ui_state['stage'] = 'results';
print faceted_search_ui_guided_block($env);

$fs_env_id 取决于您的设置。正如预期的那样,API 生成的链接将链接到实际的分面搜索环境路径。

Drupal veterans would likely be able to offer better, cleaner and more correct solutions, but the following works for me:

I added a new block which runs the following PHP:

$env = faceted_search_env_load ( $fs_env_id );
if (!$env->ready()) 
{
    $env->prepare();
    $env->execute();
}
faceted_search_ui_add_css();
$env->ui_state['stage'] = 'results';
print faceted_search_ui_guided_block($env);

$fs_env_id depends on your setup. The links generated by the API will link to the actual faceted search environment paths, as expected.

似狗非友 2024-10-13 12:52:27

唔。我不确定这是否是我正在寻找的 -

这是我现在正在使用的。我不知道这是否正是您所寻找的,但您可以在任何适用的页面上呈现构面。 (面应该显示)

对我来说,它是通过视图的搜索结果。

我正在渲染一个块,将所有搜索方面都放在一个块中。

<div class="xfacet">
Something here
<?php
$block = module_invoke('facetapi', 'block_view', 'xxxx');
print render($block['content']);
?>
</div>
<div class="xfacet">
Something there
<?php
$block = module_invoke('facetapi', 'block_view', 'xxxx');
print render($block['content']);
?>
</div>

我只是控制块显示的位置。启动后我将通过链接进行跟进。

Hmm. I am not sure if this is what I was looking for or not-

Here is what I am using now. I don't know if it is exactly what your looking for but you can render the facets on any page that is applicable. (the facets are supposed to show on)

For me it is search results via views.

I am rendering a block, with all my search facets in one block.

<div class="xfacet">
Something here
<?php
$block = module_invoke('facetapi', 'block_view', 'xxxx');
print render($block['content']);
?>
</div>
<div class="xfacet">
Something there
<?php
$block = module_invoke('facetapi', 'block_view', 'xxxx');
print render($block['content']);
?>
</div>

I just control where the block shows.I'll follow up with a link after launch.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文