getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Contoller not rendering the view #103

Closed giwrgos88 closed 8 years ago

giwrgos88 commented 8 years ago

Hello I'm new on herbert, I went throw the starting page and config page and I did all the steps one by one. I have the following view in the config file

    'views' => [
        'AdminViews' => __DIR__ . '/resources/views/admin'
    ], 

The following controller

<?php
namespace Testing\Controllers\Admin;

use Herbert\Framework\Models\Post;
use Herbert\Framework\Http;
use Herbert\Framework\RedirectResponse;

class ClientController {

    /**
     * Show a list of all clients
     */
    public function index(Http $http)
    {
        return view('@AdminViews/list.twig');
    }

    /**
     * Creates a new client
     */
    public function create()
    {

    }
}

and inside the resources/views/admin I did the following .twig with the name list <h1>testing</h1>

When I execute the controller is not showing the testing but If i write dd() or var_dump() in my index function of the controller is showing the text that i wrote inside the two functions (dd() and var_dump())

Does anyone knows why is not loading the view?

Thank you

jasonagnew commented 8 years ago

You will need to set up a route or panel which calls that controller method

Using a Route:

http://getherbert.com/0.9/routes

$router->get([
    'as'   => 'adminList',
    'uri'  => '/admin/list',
    'uses' => 'Testing\Controllers\Admin\ ClientController@index'
]);

Then you could visit: mysite.com/admin/list

Using a Panel

http://getherbert.com/0.9/panels

$panel->add([
    'type'   => 'panel',
    'as'     => 'mainPanel',
    'title'  => 'My Plugin',
    'slug'   => 'myplugin-index',
    'icon'   => 'dashicons-media-audio',
    'uses'   => 'Testing\Controllers\Admin\ ClientController@index'
]);

This would add a My Plugin menu item in the dashboard and when clicked would load your view

giwrgos88 commented 8 years ago

@jasonagnew I already did it, and the controller is called from main panel


$panel->add([
    'type'   => 'panel',
    'as'     => 'mainPanel',
    'title'  => 'CRM',
    'slug'   => 'crm-index',
    'uses'   => __NAMESPACE__ . '\Controllers\Admin\ClientController@index'
]);
giwrgos88 commented 8 years ago

Ok i found the issue, it was permission error with the cache of twig