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?
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?
Most helpful comment
Hello,
this will work:
You could also include other pages if you want to: