This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Emidelro

  • **
  • 17 posts
Best way to add custom PHP pages?
« on: March 08, 2022, 05:22:41 AM »
Hi everybody. I need to add custom PHP page to osclass that after I can access trought URL. I will put code there. What is the best way for this?. I added a new .php file on theme folder and I add the routes (following this article: https://docs.osclasspoint.com/route-functions), but not work.

I appreciate any help in advance.

*

MB Themes

Re: Best way to add custom PHP pages?
« Reply #1 on: March 08, 2022, 07:49:00 AM »
I think best way is to create plugin and create it from here.
What I mesn is to create plugin placeholder with no code at sll, define route from plugin and then create custom php pages.

Not quite sure if this would work from theme side, never tested routes in theme.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Best way to add custom PHP pages?
« Reply #2 on: March 08, 2022, 02:53:20 PM »
This is the best and simplest way

Dynamic custom pages
If you need more freedom for your pages, you can create dynamic custom pages, for example to run PHP code and create special pages. This can be easily achieved following the next steps:

Go to Add new from the Pages tab on the admin panel.
Enter a custom internal name, for example my_custom_page
Enter a tittle, body could be left empty
Create your custom file, call it page-my_custom_page.php
Upload it to your theme folder. If your theme folder is sigma, upload it to oc-content/themes/sigma.

*

MB Themes

Re: Best way to add custom PHP pages?
« Reply #3 on: March 08, 2022, 02:56:48 PM »
@cartagena68
Hmm, do you have some example of this? I think I even did not saw it yet :) .. maybe docs could be updated with this functionality.
What will be URL of such page?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Best way to add custom PHP pages?
« Reply #4 on: March 08, 2022, 03:43:04 PM »
@cartagena68
Hmm, do you have some example of this? I think I even did not saw it yet :) .. maybe docs could be updated with this functionality.
What will be URL of such page?

Was in the old osclass doc page, I just tried with osclass 8.0.1 and is working fine. https://ctg-light.plugins-zone.com/my_custom_php-p26


*

MB Themes

Re: Best way to add custom PHP pages?
« Reply #5 on: March 08, 2022, 04:30:53 PM »
Thanks for info and feedback ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

cartagena68

  • ***
  • 71 posts
Re: Best way to add custom PHP pages?
« Reply #6 on: March 08, 2022, 04:42:25 PM »
Thanks for info and feedback ;)

You're welcome.
Of course, if you want to keep the website layout you need to add header and footer of the theme in the custom page

*

Emidelro

  • **
  • 17 posts
Re: Best way to add custom PHP pages?
« Reply #7 on: March 09, 2022, 01:53:11 AM »
This is the best and simplest way

Dynamic custom pages
If you need more freedom for your pages, you can create dynamic custom pages, for example to run PHP code and create special pages. This can be easily achieved following the next steps:

Go to Add new from the Pages tab on the admin panel.
Enter a custom internal name, for example my_custom_page
Enter a tittle, body could be left empty
Create your custom file, call it page-my_custom_page.php
Upload it to your theme folder. If your theme folder is sigma, upload it to oc-content/themes/sigma.

Thanks. I had tried that method but it didn't work for me. Hitting the URL just hit a static html page (it didn't recognize my .php file).

Marked as best answer by emiliano.della-rosa on March 09, 2022, 01:50:50 PM
*

cartagena68

  • ***
  • 71 posts
Re: Best way to add custom PHP pages?
« Reply #8 on: March 09, 2022, 02:10:57 AM »

It works, if you do it right.

You create new page in oc-admin first, with title (any title) and custom internal name (for example: my_page)
Then you create your file with php code and save the file as: page-my_page.php
Upload the file page-my_page.php to the theme folder

Is working from earlier versions of osclass til now

*

Emidelro

  • **
  • 17 posts
Re: Best way to add custom PHP pages?
« Reply #9 on: March 09, 2022, 01:51:19 PM »

It works, if you do it right.

You create new page in oc-admin first, with title (any title) and custom internal name (for example: my_page)
Then you create your file with php code and save the file as: page-my_page.php
Upload the file page-my_page.php to the theme folder

Is working from earlier versions of osclass til now

Works perfectly! Thanks

*

cartagena68

  • ***
  • 71 posts
Re: Best way to add custom PHP pages?
« Reply #10 on: March 09, 2022, 02:20:38 PM »
Works perfectly! Thanks

You're welcome