Skip to main content
Answers must be a different post than the question.
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How can I show a block in a view page, excluding it'sits paginated pages?

I want to place put a block in a view page. Let's say 'news'the news page. Path, whose path is: 'http://www.mysite http://www.example.com/news.com/news'

The view uses pager to list the contentscontent.

enter image description here

enter image description here

I want a block to show up only in the very first page of 'news'the news page. (http://www.mysite.com/newshttp://www.example.com/news), excluding from paginated pages, such as news?page=1news?page=1, news?page=2 ..news?page=2.

I set the visibility to only listelist in 'news'news, but the block still shows up in but block still shows up in news?page=1, news?page=2

---------------- Updatednews?page=1, ------------------news?page=2.

FYI,How can I end upshow a solution by implements hook_context_load_alter() to remove certain blocks replacement forblock in a view page, excluding its paginated pages. Below is the code:?

/**
 * Implements hook_context_load_alter().
 */
function MYMODULE_context_load_alter(&$context) {
  
  // whether current page is under paginated pages. e.g 'news?page=1'
  $paged = (strpos(request_uri(), '?page=') !== false) ? TRUE : FALSE;

  // if yes and context is the specific one:
  if ($context->name === 'news_front' && $paged ) {
    
    // remove particular block placement:
    if (isset($context->reactions['block']['blocks']['views-nodequeue_1-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_1-block']);
    }
    
    if (isset($context->reactions['block']['blocks']['views-nodequeue_2-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_2-block']);
    }
  }
}

How can I show a block in a view page, excluding it's paginated pages

I want to place put a block in a view page. Let's say 'news' page. Path is: 'http://www.mysite.com/news'

The view uses pager to list the contents.

enter image description here

I want a block to show up only in the very first page of 'news' page. (http://www.mysite.com/news), excluding from paginated pages, such as news?page=1, news?page=2 ...

I set the visibility to only liste in 'news', but block still shows up in news?page=1, news?page=2

---------------- Updated ------------------

FYI, I end up a solution by implements hook_context_load_alter() to remove certain blocks replacement for paginated pages. Below is the code:

/**
 * Implements hook_context_load_alter().
 */
function MYMODULE_context_load_alter(&$context) {
  
  // whether current page is under paginated pages. e.g 'news?page=1'
  $paged = (strpos(request_uri(), '?page=') !== false) ? TRUE : FALSE;

  // if yes and context is the specific one:
  if ($context->name === 'news_front' && $paged ) {
    
    // remove particular block placement:
    if (isset($context->reactions['block']['blocks']['views-nodequeue_1-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_1-block']);
    }
    
    if (isset($context->reactions['block']['blocks']['views-nodequeue_2-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_2-block']);
    }
  }
}

How can I show a block in a view page, excluding its paginated pages?

I want to place put a block in a view page. Let's say the news page, whose path is http://www.example.com/news.

The view uses pager to list the content.

enter image description here

I want a block to show up only in the very first page of the news page (http://www.example.com/news), excluding from paginated pages, such as news?page=1, news?page=2.

I set the visibility to only list in news, but the block still shows up in news?page=1, news?page=2.

How can I show a block in a view page, excluding its paginated pages?

add context tag for better referencing
Link
gilzero
  • 6k
  • 9
  • 55
  • 71
my solution
Source Link
gilzero
  • 6k
  • 9
  • 55
  • 71

I want to place put a block in a view page. Let's say 'news' page. Path is: 'http://www.mysite.com/news'

The view uses pager to list the contents.

enter image description here

I want a block to show up only in the very first page of 'news' page. (http://www.mysite.com/news), excluding from paginated pages, such as news?page=1, news?page=2 ...

I set the visibility to only liste in 'news', but block still shows up in news?page=1, news?page=2

---------------- Updated ------------------

FYI, I end up a solution by implements hook_context_load_alter() to remove certain blocks replacement for paginated pages. Below is the code:

/**
 * Implements hook_context_load_alter().
 */
function MYMODULE_context_load_alter(&$context) {
  
  // whether current page is under paginated pages. e.g 'news?page=1'
  $paged = (strpos(request_uri(), '?page=') !== false) ? TRUE : FALSE;

  // if yes and context is the specific one:
  if ($context->name === 'news_front' && $paged ) {
    
    // remove particular block placement:
    if (isset($context->reactions['block']['blocks']['views-nodequeue_1-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_1-block']);
    }
    
    if (isset($context->reactions['block']['blocks']['views-nodequeue_2-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_2-block']);
    }
  }
}

I want to place put a block in a view page. Let's say 'news' page. Path is: 'http://www.mysite.com/news'

The view uses pager to list the contents.

enter image description here

I want a block to show up only in the very first page of 'news' page. (http://www.mysite.com/news), excluding from paginated pages, such as news?page=1, news?page=2 ...

I set the visibility to only liste in 'news', but block still shows up in news?page=1, news?page=2

I want to place put a block in a view page. Let's say 'news' page. Path is: 'http://www.mysite.com/news'

The view uses pager to list the contents.

enter image description here

I want a block to show up only in the very first page of 'news' page. (http://www.mysite.com/news), excluding from paginated pages, such as news?page=1, news?page=2 ...

I set the visibility to only liste in 'news', but block still shows up in news?page=1, news?page=2

---------------- Updated ------------------

FYI, I end up a solution by implements hook_context_load_alter() to remove certain blocks replacement for paginated pages. Below is the code:

/**
 * Implements hook_context_load_alter().
 */
function MYMODULE_context_load_alter(&$context) {
  
  // whether current page is under paginated pages. e.g 'news?page=1'
  $paged = (strpos(request_uri(), '?page=') !== false) ? TRUE : FALSE;

  // if yes and context is the specific one:
  if ($context->name === 'news_front' && $paged ) {
    
    // remove particular block placement:
    if (isset($context->reactions['block']['blocks']['views-nodequeue_1-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_1-block']);
    }
    
    if (isset($context->reactions['block']['blocks']['views-nodequeue_2-block'])) {
        unset($context->reactions['block']['blocks']['views-nodequeue_2-block']);
    }
  }
}
type
Link
gilzero
  • 6k
  • 9
  • 55
  • 71
Loading
Tweeted twitter.com/#!/StackDrupal/status/261709488996896768
Source Link
gilzero
  • 6k
  • 9
  • 55
  • 71
Loading