UI appearance and functionality can be modified by creating a custom CSS or JavaScript file. AdminNeo will automatically include files adminneo.css, adminneo-light.css, adminneo-dark.css and adminneo.js that are placed in the AdminNeo's current working directory (typically next to the adminneo.php or index.php). File structure will be:
– adminneo.php
– adminneo.css
ℹ️ Note: Multiple CSS and JS files can be also defined in cssUrls and jsUrls configuration parameters.
It is possible to override methods in the \AdminNeo\Admin
class for deeper integration. It can be done in
adminneo-instance.php file.
File structure will be:
– adminneo.php
– adminneo-instance.php
You can freely rename adminneo.php to index.php.
The file adminneo-instance.php will return a custom instance derived from Admin
:
<?php
class CustomAdmin extends \AdminNeo\Admin
{
public function getServiceTitle()
{
return "Custom Service";
}
}
// Use factory method to create CustomAdmin instance.
return CustomAdmin::create();
Factory method create()
accepts also configuration and plugins, so everything can be defined in one
adminneo-instance.php file:
<?php
class CustomAdmin extends \AdminNeo\Admin
{
public function getServiceTitle()
{
return "Custom Service";
}
}
// Define configuration.
$config = [
"colorVariant" => "green",
"navigationMode": "dual",
"preferSelection": true,
"recordsPerPage": 70,
];
// Enable plugins.
$plugins = [
new \AdminNeo\JsonPreviewPlugin(),
new \AdminNeo\XmlDumpPlugin(),
new \AdminNeo\FileUploadPlugin("data/"),
];
// Use factory method to create CustomAdmin instance.
return CustomAdmin::create($config, $plugins);
ℹ️ Note: Compiled versions of AdminNeo and EditorNeo are downgraded to support PHP 5.4+. That means you have to
adapt function declarations for PHP 5. It basically means stripping parameter types. For example method authenticate()
will
look like this:
public function authenticate($username, $password)
{
// username: 'admin', password: anything
return ($username == 'admin');
}
The functionality of EditorNeo is limited and one of the most fundamental customizations is setting the database.
By default, EditorNeo picks the first available database for the logged-in user. To change this,
override the getDatabase()
method in the adminneo-instance.php file:
<?php
class CustomEditor extends \AdminNeo\Admin
{
public function getDatabase()
{
return "my_database_name";
}
}
// Use factory method to create CustomEditor instance.
return CustomEditor::create();
A very similar use case is setting up EditorNeo for use with a SQLite database:
<?php
class CustomEditor extends \AdminNeo\Admin
{
public function getDatabase()
{
return "/path/to/your/database_file.db";
}
public function getLoginFormRow($fieldName, $label, $field)
{
// Hide username field.
if ($fieldName == "username") {
return "";
}
return parent::getLoginFormRow($fieldName, $label, $field);
}
}
$config = [
"defaultDriver" => "sqlite",
// Warning! Inline the result of password_hash() so that the password is not visible in the source code.
"defaultPasswordHash" => password_hash("YOUR_PASSWORD_HERE", PASSWORD_DEFAULT),
];
// Use factory method to create CustomEditor instance.
return CustomEditor::create($config);
Another option is to create the \AdminNeo\Admin
instance inside your own index.php file.
In this case, implement adminneo_instance()
function in the global namespace and include AdminNeo file
placed in the non-public directory:
<?php
function adminneo_instance()
{
// Define configuration.
$config = [
"colorVariant" => "green",
];
// Use factory method to create Admin instance.
return \AdminNeo\Admin::create($config);
}
// Include AdminNeo file.
include "/non-public-path/adminneo.php";
Or with derived class and plugins:
<?php
function adminneo_instance()
{
class CustomAdmin extends \AdminNeo\Admin
{
public function getServiceTitle()
{
return "Custom Service";
}
}
// Define configuration.
$config = [
"colorVariant" => "green",
];
// Enable plugins.
$plugins = [
new \AdminNeo\JsonPreviewPlugin(),
new \AdminNeo\XmlDumpPlugin(),
new \AdminNeo\FileUploadPlugin("data/"),
];
// Use factory method to create Admin instance.
return CustomAdmin::create($config, $plugins);
}
// Include AdminNeo file.
include "/non-public-path/adminneo.php";