Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route using template not working #902

Open
YassineBenaziz opened this issue Oct 13, 2023 · 1 comment
Open

Route using template not working #902

YassineBenaziz opened this issue Oct 13, 2023 · 1 comment

Comments

@YassineBenaziz
Copy link

  • Themosis Version: 3.1.0
  • WordPress Version: 6.3.1
  • PHP Version: 8.1.12

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
Copy link

deep80 commented Nov 11, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants