Contentify: [Question] Hide Slider on all but Home Page

Created on 29 Mar 2017  路  5Comments  路  Source: Contentify/Contentify

I feel as though the slider is something that should only be viewable on the home page.

I haven't had any luck using this:

@if (stripos($_SERVER['SCRIPT_NAME'], 'index.php'))
     @widget('Slides::Slides', ['categoryId' => 1])
@endif

Because it targets multiple pages... How would I get it to target just the home page?

help wanted question

Most helpful comment

Hello,

this will work:

    @if(Request::url() == url('/'))
        @widget('Slides::Slides', ['categoryId' => 1])
    @endif

You could also include other pages if you want to:

    @if(Request::url() == url('/') or Request::url() == url('/teams'))
        @widget('Slides::Slides', ['categoryId' => 1])
    @endif

All 5 comments

Hello,

this will work:

    @if(Request::url() == url('/'))
        @widget('Slides::Slides', ['categoryId' => 1])
    @endif

You could also include other pages if you want to:

    @if(Request::url() == url('/') or Request::url() == url('/teams'))
        @widget('Slides::Slides', ['categoryId' => 1])
    @endif

Thanks, this worked!

@chriskonnertz Could we perhaps have it as an option in backend > sliders?
鉁旓笍 Show only on homepage or something?

Funny, I was thinking about that as well, yesterday.

Good question.

What I thought was: This is a good example where _not_ having an option in the backend is okay, because it is very easy to do this customization. :P

But I also agree that the slider should not be included to every page. So I believe that this custom solution should "officially" be integraded in the default templates. I do not think we really need the option, because I guess (almost) everyone likes the idea of only displaying it on the landing page - do you agree?

Yes, I think it would be easier (and more "seldom") to do support WHEN people want it to show on all the pages rather than the other way around.

BTW: are the @ifs the best way?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kamohy picture kamohy  路  5Comments

LeventeNagy picture LeventeNagy  路  4Comments

andakawa picture andakawa  路  4Comments

Devilcraft1407 picture Devilcraft1407  路  3Comments

niclasreich picture niclasreich  路  4Comments