ekandreas / bladerunner

WordPress plugin for Laravel Blade templating DEPRECATED
http://bladerunner.elseif.se
12 stars 1 forks source link

Can't set up Controllers #81

Closed lexdubyna closed 3 years ago

lexdubyna commented 5 years ago

I am having some troubles setting up Controllers for specific pages. My file structure

theme_root/
    index.php

    controllers/
        Home.php

    views/
        page/
             home.blade.php
             ...
        single/
             post.blade.php
             ...

Home.php

<?php

namespace App;

use Bladerunner\Controller;

class Home extends Controller
{
    protected $view = 'views.page.home';

    public function helloWorld()
    {
        return 'Hello World!';
    }
}

But when I use {{ $helloWorld }} in my view, I get a notice Undefined variable: helloWorld.

JockeTF commented 5 years ago

This is just a hunch, but try calling the variable helloworld.

Bladerunner may have issues with capital letters.

lexdubyna commented 5 years ago

@JockeTF I've read simillar issues about capital letters. I tried calling helloworld and renaming method helloworld and renaming class to home and file to home.php , but unfortunately nothing worked. I used @controller in views/page/home.blade.php, which showed me this:

Controller:

Data:Array
(
)

Controller Template Hierarchy (first has highest prio):
     front-page.blade.php
     front-page.php
     page-home.blade.php
     page-home.php
     page-15.blade.php
     page-15.php
     page.blade.php
     page.php
     singular.blade.php
     singular.php
     index.php

I guess my controller doesn't fire at all and maybe the problem is with protected $view = 'views.page.home' (which just may not work).

ekandreas commented 3 years ago

Hi! This is a deprecated package. Please use https://github.com/EFTEC/BladeOne instead!