I created an application that allows admins to save slider content to the database and now I want to include the slider on the home page. I have a Slides controller with a slider function that just send the slides content to the slider view.
Here is that controller function:
public function slider()
{
$slides = $this->Slides->find('all');
$this->set('slides', $slides);
$this->set('_serialize', ['slides']);
}
The view for that function only has the following in it:
<?= $this->element('slider'); ?>
I then created an element file called slider and process the slides there. When I go to url /slides/slider the slider is working, but when I go to the root or home page, the slider is empty. It doesn't seem to be keeping the $slides variable in the element.
On the home page:
<?= $this->element('slider'); ?> // then the rest of the home page follows this.
So how do I keep the variable or make it so that I can have the slider view on the home page as well?