Custom pages in AppGini are just awesome, and I'm using them a lot. There is one backdraw you might have seen: Custom Pages don't have a (browser-) title by default. That may be irritating for users, when saving custom pages as bookmarks or when sharing links. I am showing a simple PHP one-liner which defines the title of the custom page.
When loading standard AppGini pages like Table Views or Detail Views there is a specific browser title which is a concatenation of App-Title + Page-Title:
That's fine for example when saving this page as bookmark.
But when creating custom pages, there is no default page title, so the browser title is incomplete:
Every custom page will have the identical page title, which is just the App's title.
Let's have a look at the code for a standard (almost empty) custom page:
<?php // file: testpage.php include("lib.php"); include("header.php"); echo '<h1>Custom Page</h1>'; include("footer.php");
This just gives a custom page with a
<h1>-title but no specific browser-title.
You will see in included
header.php there is a concatenation of
APP_TITLE + Pipe-character
<title><?php echo APP_TITLE . (isset($x->TableTitle) ? ' | ' . $x->TableTitle : ''); ?></title>
$x is defined in Table Views, Detail Views and perhaps some other pages but not in Custom Pages.
So, let us quickly change this by defining some dummy
$x variable and setting the
TableTitle. Check out the following code, especially line 4:
<?php // file: testpage.php include("lib.php"); $x = (object)["TableTitle" => "This is my Custom Page"]; include("header.php"); echo '<h1>Custom Page</h1>'; include("footer.php");
This line 4 declares a variable named
$x as a (standard-) object and sets the value of the property
TableTitle to some sample-text.
And this is the (wanted) output:
It is important to declare
$x->TableTitle before including
That's it. Now, saved bookmark for or shared links to Custom Pages will have a specific, customizable title.