I want to show a view in <front> page but only in the front page.
When I choose in the .pager to "Go to page 1" (or any other pages from the pager) the view is in the top of all pages...

How can I show a view/block ONLY in front page?

I'm missing something or this is a real bug? I always though the front page was the first page only not all other pages from the pager. Since articles are presented in time, all posts with "Promoted in front page" should be a continuous timeline with them after each other... Hence the "Front Page" should be the First page!

Solution: https://drupal.org/node/2213313#comment-8557141

Comments

nevets’s picture

Is your view meant to replace the default front page? If yes, you want your view to have a page display and the under site information make that your new front page.

kryptum’s picture

No my view is a block.

I used the option: "Show block on specific pages - Only the listed pages: <front>" but doesn't work.

Also tried_ "Show block on specific pages - All pages except those listeds: /*" but doesn't work.

I also made a section and used "drupal is front" like this:

    <?php if ($is_front): ?>
      <div id="welcome"><?php print render($page['welcome']) ?></div>
    <?php endif; ?>

Does not work either...

I really need this block to show in top of front page only, I mean the front page only... Almost 48h searching and reading through internet without luck... :(

I'm now searching trough all Views options to see if there's some option for this but I'm getting almost desesperated to do this simple thing. If anyone know some contextual filter or module please refer it. This is a must and I'm getting without time.

Thank you.

nevets’s picture

When you try

I used the option: "Show block on specific pages - Only the listed pages: " but doesn't work.

what does "doesn't work" mean. (it should).

jaypan’s picture

I used the option: "Show block on specific pages - Only the listed pages: " but doesn't work.

Then you have a bug in your system, because this is how it works. You need to track down the module/theme that is causing this non-standard behavior.

1) Put your site in maintenance mode
2) Take a database backup
3) Change your theme. Test again. If problem is fixed, it's a theme issue. Skip to last step.
4) Start disabling modules one at a time, checking after each disable. When problem is fixed, the last module you disabled was the culprit.
5) Re-install the database backup you took in step 2 to revert your system to its original state. Take your site out of maintenance mode.

Come back here when you know which module/theme was causing this non-standard behavior.

Contact me to contract me for D7 -> D10/11 migrations.

kryptum’s picture

Actually I think this is a core bug.

What I did:

  • Tried every single core template —> Not working
  • Disabled ALL modules —> Not working
  • Create a section with ($is_front) —> Not working

Sugestion:

  • Enabled any block to show on any section and choose "Show block on specific pages - Only the listed pages: <front>".
  • Go to your front page, scroll down to the navigation Pager and choose any page.
  • You see, the module is visible in all pages from Front page.

Can anyone help with some php code to remove the block if there's any string in the url? This would make it visible only in the first page of the "Front page".
I need to include a Welcome block but it is not functional to show it in all pages from the pager...

[EDIT]

Finally I found something wow...
You may not agree with my point of view but for me this is a crucial bug. Imagine a welcome message in "all pages from Front page", not functional and not cool !!!

I found this article and will try this suggestions:
http://www.nzwhost.com/article/drupal-display-content-front-page-only

[EDIT 2]

I found the solution. Following the previous link article I came with this:

<?php

$url = request_uri();
if ($is_front and (!strpos($url, "?"))) { ?>

  <div id="welcome"><?php print render($page['welcome']) ?></div>

<?php } ?>

This code will print in page.tpl.php file a section called "Welcome" that is shown only in the first page (first page only, not in all pages from front page)...

The code (in my understanding) checks if the page is front and if it doesn't have the "?" caracter in the url, then prints this section.

As you notice when you click in a link from pager it will apply /node?page=1, /node?page=2, /node?page=3, etc... to the url address so the only way I found to check if the front page is the first page is to search for this in the uri.

Everything is working fine. If you have a simpler way or different solution please share in future. Thanks.

jaypan’s picture

Ahh, I understand your issue now. I don't think I'd classify this as a bug so much as a difference in understanding between your expectations, and how the system works.

That said, it would be nice to include this option somehow on the block configuration.

Contact me to contract me for D7 -> D10/11 migrations.

kryptum’s picture

Yes it would be very nice to have the option. A welcome message should only be visible in the first page...

Also would be nice to have the option to "Hide" blocks from the Admin Block page. I have a lot of blocks I don't use and it's frustrated sometimes to have them all stacked up...