1060

How to create a default home page with Trongate Pages?

Comments for “How to create a default home page with Trongate Pages?”
 

Posted by Balazs on Monday 6th May 2024 at 01:37 GMT

I created a page called "My Home Page" using the Trongate Pages CMS module.
It is currently available at: localhost/my_app/trongate_pages/display/my-home-page

How can I set it to be the default home page when someone visits my website's BASE_URL (localhost/my_app/)?

I tried to set the default module, controller and method in config.php:

define('DEFAULT_MODULE', 'trongate_pages');
define('DEFAULT_CONTROLLER', 'Trongate_pages');
define('DEFAULT_METHOD', 'display');


Of course, it's giving me an error because I need to somehow let the display() method know that I want to show "my-home-page". How should I go about that?

Or is there something I could do in custom_routing.php to make it work?
Any help is appreciated.
Level One Member

Balazs

User Level: Level One Member

Date Joined: 8/04/2023

Posted by DaFa on Monday 6th May 2024 at 03:42 GMT

Hi Balazs,

Trongate Pages is treated differently with its routes and will allow you to go directly to your pages - like so:
localhost/my_app/{anything}/my-home-page
This means you can insert literally 'anything' between 'host_name' and your page slug - in your case 'my-home-page'. You can even omit segment(1) and have
localhost/my_app/my-home-page
or
localhost/my_app/blog/personal/stuff/for/balazs/my-home-page
and it will still work.
As for setting your default page, you are better off leaving the default welcome page as is in config.php and adding a redirect for the index method:
function index() {
        redirect('my-home-page');
}

This comment was edited by DaFa on Monday 6th May 2024 at 03:45 GMT

Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by Balazs on Monday 6th May 2024 at 14:02 GMT

Hello DaFa,

Thank you very much for your quick and helpful response.
I didn't know Trongate Pages handles routes so gracefully. Amazing!

The Trongate Pages module really is a game-changer and sets Trongate apart from other frameworks. Where can I learn more about Trongate Pages?
Level One Member

Balazs

User Level: Level One Member

Date Joined: 8/04/2023

Posted by DaFa on Monday 6th May 2024 at 22:25 GMT

The docs are being rewritten as we speak and DC has just put the call out for anyone willing to help.
https://youtu.be/6jtiZdUwibo?si=bpKvjKe4AGvEOk2_

Also, I forgot to mention with the above redirect you could also add your own middleware prior to the redirect, like stat logging etc..to your page.

This comment was edited by DaFa on Monday 6th May 2024 at 22:26 GMT

Founding Member

DaFa

User Level: Founding Member

Date Joined: 30/11/2018

Posted by Balazs on Tuesday 7th May 2024 at 00:51 GMT

Great, thank you again DaFa!
Level One Member

Balazs

User Level: Level One Member

Date Joined: 8/04/2023

×