Default page for anonymous user

How to set anonymous default page?

If you use Dynamic User Level Security, then you may simply login to the generated web application by using admin user, and go to User Levels List page, click on Permissions for Anonymous user level, then in the next page, you may simply enable List permission for your desired the tables/pages.

What if I have 4 tables and 2 custom files with list permissions for anonymous users? I want the Default page to be home.php the custom file not the other tables.
Scenario
I have 2 custom files: home.php and dash.php, when a user is not logged in, default is home.php and when logged in its dash.php

You may try use add a function in server side Global Code, e.g. (v2021.0.7 or newer)

function myStartPage() {
return IsLoggedIn() ? "dash" : "home";
}

and set the Start Page as “myStartPage”.

Thank you, amazing - now we have better control over the pages users will have access

I have tried this in v2022:Added to the Global Code Server Events:

function myStartPage() {
return IsLoggedIn() ? "clientslist" : "anonlook";
}

Set the Start Page in the generation page as myStartPagebut then I get the following:

404
Error
Route 'myStartPage' not found.

Thanks!

Make sure you have already re-generated ALL the script files again.

Note that server side global code is generated in src\userfn.php, make sure you have generated and uploaded to your site again.

I have deleted the contents of the project folder, regenerated all the files (F9)I can see the function at the end of the src\userfn.php file

// Container Build event
function Container_Build($builder)
{
    // Example:
    // $builder->addDefinitions([
    //    "myservice" => function (ContainerInterface $c) {
    //        // your code to provide the service, e.g.
    //        return new MyService();
    //    },
    //    "myservice2" => function (ContainerInterface $c) {
    //        // your code to provide the service, e.g.
    //        return new MyService2();
    //    }
    // ]);
}

function myStartPage() {
return IsLoggedIn() ? "clientslist" : "anonlook";
}

still I get the 404 error with
Route ‘myStartPage’ not found.If I navigate to any other page everything works, but the moment I click on the home icon I get the 404 Route ‘myStartPage’ not found.Thanks

The problem is the link on the Breadcrumb link try to open myStartPage and give error

wungaz wrote:

The problem is the link on the Breadcrumb link try to open myStartPage and give error

I have added the following script on Page_Rendering()
Breadcrumb()->Links[0][2] = “home”;
When users click on the Home Icon button from other pages it takes them to home

wungaz wrote:

The problem is the link on the Breadcrumb link try to open myStartPage and give error

Which PHPMaker version are you using?

You probably are using some older version. The latest version (v2022.1) works fine.

wungaz wrote:

The problem is the link on the Breadcrumb link try to open myStartPage and give error

On Generate settings in the Start Page field put the following: “.MyStartPage().”
including the quotation marks and full stops.This is needed because the code in file Error.php is: ‘’‘$Breadcrumb = new Breadcrumb(“”);’''So now your quotation marks are neautralising the quotation marks in the code and the procedure MyStartPage() gets called in between the full stops.This is how I fixed it. Using v2021.0.15