Alot of this stuff doesn't work

So I spent all weekend rebuilding my website from the ground up using a new CMS I've never tried before, and while I was successful, it was really really obnoxious in several regards, many of those things I've laid out already, but there's a solution I had to figure out myself that none of the OctoberCMS forums, tips pages, or anything actually touch on.

When you write php code to go along with your website, there's functions you can use like onStart, onEnd, onRender, if you're familliar with Unity at all they have a similar type of deal for stuff where you want your object to update every frame.

What I had found online indicated you could reference the components you pass into the page template, like for example, blogPost. blogPost has several attributes you can reference in the template like the content and the title and the published date and all that jazz, you do it similar to Django.

For whatever reason this seems to be impossible to use from the php code. The things I found online said I could do it, but no, it doesn't work, what it component['blogPost'] gave to me instead was information about the class, not the object, so I couldn't actually get anything useful out of it

So if you wanted to, I don't know, change the page title, a thing you normally define in a partial, you would do it via PHP but if you want it to be the title of the blog post, fuck you I guess. It lets you pull out blogPost and then you have to use the dump() function to see what it's actually doing, after you've tried to reference the title attribute a hundred times only to be met with an Internal Server 500 error.

Instead, I had to figure out how to use the Model Query syntax. Since I recently wrote a Django app this isn't too foreign to me but it seems strange that if I pass in a component to the page I can only use it in the half of the page code that's less dynamic.


function onStart(){
    //$data= $this->page->components['blogPost'];  //doesnt fucking work?????
    //echo dump($data);
    $slug=$this->param('slug');
    $title=RainLab\Blog\Models\Post::where('slug',$slug)->first()->title;
    //$category=Rainlab\Blog\Models\Category::where('slug','gta-san-andreas')->first()->name;
    //echo dump($category);
    //echo dump($title);
    $this->page->title=$title;
}