themosis / framework

The Themosis framework core.
https://framework.themosis.com/
GNU General Public License v2.0
671 stars 121 forks source link

Route using template not working #902

Open YassineBenaziz opened 1 year ago

YassineBenaziz commented 1 year ago

Description

I'm trying to set a new route ( in my routes.php located in my theme, or in web.php route file located in PROJECT_ROUTE/routes/web.php ) using a custom template, but this is not working.

Steps to reproduce

Here is the content of my templates.php file :

return [
    'custom-template' => [__('Custom Template', THEME_TD), ['page']]
];

Then I go to the wordpress backoffice and I create a new page and with my custom-template model.

In my routes files I have set this :


Route::any('template', ['custom-template', 'uses' => 'PageController@custom']);

Route::any('/', 'HomeController@index');
Route::any('page', 'PageController@index');
.
.
.

When I try to access to my page with my custom template, It returns the view in the PageController@index instead of the one in PageController@custom.

And when i try log this in my controllers : $query->is_page_template() It returns false.

Expected behavior

I should get the view rendered from PageController@custom.

Thanks you .

deep80 commented 1 year ago

I am also getting the same issue here. however in my case when I use is_page_template('template-name') function it's returning true. therefore what i do is check using the is_page_template() and returning the view accordingly at the controller level. that's a work around and it's not good, since the template routing is documented.