简体   繁体   English

如何在drupal 7中显示除当前页面以外的兄弟页面?

[英]How to display sibling pages except current page in drupal 7?

Suppose I have parent pages A1 and B1. 假设我有父页面A1和B1。 A1 has child pages A1.1, A1.2,A1.3 and B1 has child pages B1.1, B1.2. A1具有子页面A1.1,A1.2,A1.3,而B1具有子页面B1.1,B1.2。

When I am on page A1.1 I shall be able to display A1.2 and A1.3. 当我在A1.1页上时,我将能够显示A1.2和A1.3。 Same for A1.2, I shall be able to see A1.1 and A1.3. 与A1.2相同,我将能够看到A1.1和A1.3。

If I am on page B1.1, I shall see B1.2 and vice versa. 如果我在B1.1页上,我将看到B1.2,反之亦然。

Note: Every page has an image and a title. 注意:每个页面都有图像和标题。 I want to get a solution using views. 我想使用视图获取解决方案。

This thread may be linked to this link if we need the child pages: How to list all child pages of current parent page in drupal 7? 如果我们需要子页面,则可以将此线程链接到此链接: 如何在drupal 7中列出当前父页面的所有子页面?

在两个页面上添加一个上下文过滤器nid,默认情况下,从url中选择内容ID,然后在下面的“预先”部分中选中“排除”选项。

I managed to do it by creating a view with the following php code in contextual filter 我设法通过在上下文过滤器中使用以下php代码创建视图来做到这一点

$sibbling = array();
$current = db_query("select menu_name, mlid from {menu_links} where link_path = :node", array(':node' => $_GET['q']));
$current_info = array();
foreach ($current as $value) {
    $current_info[] = $value;
}
if($current_info) {
    $result = db_query("select mlid, plid, link_path, link_title from {menu_links} where link_path != :node and plid = ( select plid FROM {menu_links} WHERE link_path =:node)", array(':node' => $_GET['q']));
    foreach ($result as $row) {
      $sibbling[] = $row;
    }
}
$nids = array();

foreach ($sibbling as $value){
    if( substr( $value->link_path, 0, 5 ) == 'node/' ){
        $nids[] = substr( $value->link_path, 5 );
    }
}

return implode('+',$nids);

And finally in the plus options we got to check "Allow multiple values " 最后,在加号选项中,我们必须选中“允许多个值”

Save and its done ;-) 保存并完成;-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 drupal 7 中列出当前父页面的所有子页面? - How to list all child pages of current parent page in drupal 7? 在Drupal的分页页面(第一页除外)上未加载自定义Javascript - Custom Javascript Not Loading On Paginated Pages (Except First Page) In Drupal 如何在 Drupal 中获取当前页面 URL? - How to get current page URL in Drupal? 如何在 drupal 日历页/块上显示 Drupal Commerce 用户订单? - How to display Drupal Commerce user orders on drupal calendar page/block? Drupal:如何在视图页面中显示块/区域? - Drupal: How to display block/region in views page? 如何在 Drupal 中显示一个简单的自定义页面? - How to display a simple custom page in Drupal? 如何在Drupal 7的分类术语页面上显示预告片 - How to display teaser on taxonomy term page in Drupal 7 除了 Drupal 站点中的 2 个页面之外,如何将整个站点从 HTTP 重定向到 HTTPS? - how to redirect complete site from HTTP To HTTPS except for 2 pages in Drupal Site? 如何在儿童页面显示菜单所有儿童页面drupal - How to show menu in children page`s all children pages drupal 如何在首页drupal 8上显示“与我们联系”页面? - how can i display contact us page on front page drupal 8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM