Hello,
i’m fairly new to Cake, and i’m facing the following logical problem for me:
I’ve created a Theme as a Plugin for my Cake Site, in which i created a layout for the home page (home.ctp) and a layout for the default pages (default.ctp). Now i’ve further created a simple appointments plugin. My Question: How do i make the data from the appointment plugin available in theme plugin?
In my case, i need to use the appointment object from the apointment plugin in my theme plugin. Which means that i have no access to the appointments from the AppController inside the theme plugin. Is there some way to pass the appointments to my theme plugin?
Yeah, i had that idea aswell. I’m just stuck in how to do so. I just simply want to load all appointments inside one of my theme-views, and display them. I tried to create a helper in my plugin, named AppointmentHelper. In the docs i read that you can use a helper inside a plugin (the theme in my case) with
public $helpers = [‘Appointment.Appointment’];
But that is not getting me anywhere. I’d wish theming would be better documentend in Cake v3, it is a bit hard to see through as a beginner
First of all, i’m using Cake 3.5.17, which comes with croogo, which i use.
All i want is to be able to use all my appointment data in the default view of my theme. My theme is a plugin called DefaultTheme. I am not even sure if a helper is the right thing to do this way, but as you suggested it too, i want to try it that way.
I’ve now created an AppView for my theme:
/plugins/DefaultTheme/src/View/AppView.php
In this app i try to load the AppointmentHelper like this:
class AppView extends View
{
public function initialize()
{
parent::initialize();
$this->loadHelper('Appointment');
}
}
This doesn’t make it available inside my view. Any idea?
and let the function return $appointments. Now i can use the data in my default view for my theme. It feels wrong though, if someone can help me to find a better way i’d approve.