getherbert / herbert

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

Shortest way of making a link from a view to another view #95

Open imboden opened 8 years ago

imboden commented 8 years ago

Hello,

Sorry for this "newbie" question but what is the shortest way for making a link from page 1 to page 2. Don't really get it from the example module. Thanks

dcalvert commented 8 years ago

If you are creating a link from one page to another in the admin area then use:

{{ panel_url('NameOfPlugin::myplugin-index') }}

when you have a panel (in panels.php) that looks like:

$panel->add([
    'type'   => 'panel',
    'as'     => 'mainPanel',
    'title'  => 'My Plugin',
    'slug'   => 'myplugin-index',
    'uses'   => __NAMESPACE__ . '\Controllers\AdminController@index'
]);

If its on the public facing side use the following in your template:

<a href="{{ route_url('NameOfPlugin::profile') }}">click me!</a>

when you have a route (in routes.php) that looks like:

$router->get([
    'as'   => 'profile', 
    'uri'  => '/simple',
    'uses' => __NAMESPACE__ . '\Controllers\UserController@profile]
);

I hope this helps.