cubecart / v6

CubeCart Version 6
https://cubecart.com
73 stars 57 forks source link

Admin Sections to Have Meta Titles #3456

Open bhsmither opened 10 months ago

bhsmither commented 10 months ago

Feature Request:

Similar in concept to deriving and sending Meta information to the storefront templates, also derive and send Meta information to the admin templates.

My experiments suggest:

ACP->importNode, add anywhere:
$GLOBALS['seo']->set_meta_data(['name' => ucfirst($request), 'title' => ucfirst($request)]);
$GLOBALS['seo']->displayMetaData();

Admin template main.php:
<title>{$META_TITLE} - {$LANG.dashboard.title_admin_cp}</title>

This does not yet find the Dashboard. Nor does it use the $node if not empty.

This puts, for example, Statistics - My Store - Admin Control Panel on the browser's header and tab.

This is convenient when one has many browser windows open, or many tabs open in one browser -- where otherwise all of them saying just Admin Control Panel.

bhsmither commented 10 months ago

More experiments give this:

In controller.admin.session.true.inc.php, find:
if (isset($_GET['_g']) && !empty($_GET['_g']) && $_GET['_g'] != 'plugins') {
    $GLOBALS['gui']->addBreadcrumb(ucwords($_GET['_g']));
}

Add after:
$GLOBALS['seo']->set_meta_data([
  'name'  => ucfirst(preg_replace('/[^a-z0-9._-]/', '', $_GET['node'] ?? $_GET['_g'] ?? 'dashboard')),
  'title' => ucfirst(preg_replace('/[^a-z0-9._-]/', '', $_GET['node'] ?? $_GET['_g'] ?? 'dashboard'))
]);
$GLOBALS['seo']->displayMetaData();

Do not use importNode().

bhsmither commented 10 months ago

However, this uses the script name, which in some cases, does not accurately match the actual name of the section. Also, there is no incorporation of phrases from the language pack.

abrookbanks commented 10 months ago

This is cool. Same it's not so accurate with the name. I think there needs to be some manual mapping which is a shame.