Browse files

Implement page slugs

Closes #3.
  • Loading branch information...
cmb69 committed Nov 21, 2016
1 parent 33ae514 commit e6f381ab9fd0feb4130ae1612725a5b402b9d26c
Showing with 81 additions and 1 deletion.
  1. +28 −0 help/help.htm
  2. +1 −1 help/stylesheet.css
  3. +6 −0 index.php
  4. +3 −0 languages/en.php
  5. +20 −0 seo_tab.php
  6. +23 −0 userfuncs.php
@@ -43,6 +43,12 @@ <h2>Installation</h2>
<li>Unzip the distribution on your computer.</li>
<li>Upload the whole directory seo/ to your server into CMSimple_XH's plugins/ directory.</li>
<li>Set write permissions to the subdirectories config/ und languages/.</li>
If you want to use <a href="#usage-slugs">Page Slugs</a>, move userfuncs.php into the cmsimple/
folder in the root of the CMSimple_XH installation. If there is already a userfuncs.php, copy
the contents of Seo_XH's userfuncs.php into the existing file. Take care to properly handle the
PHP start and end tags (&lt;?php and ?&gt;).
<!--<li>Browse to Pagemanager's administration (Plugins &rarr; Pagemanager), and
check if all requirements are fulfilled.</li>-->
@@ -101,6 +107,28 @@ <h3>Canonical Links</h3>
the configuration option Canonical→Include.
<section id="usage-slugs">
<h3>Page Slugs</h3>
CMSimple_XH constructs the URLs to access the individual pages from the page
headings. This means that any change to the page heading changes the URL of the
page, so that existing bookmarks won't work anymore. To avoid that you can keep the
old page heading, and set an <a
Heading</a> instead, or you can use Moved_XH to cater to such changes.
However, Seo_XH offers an alternative solution, so called page slugs. For each page
a slug can be entered in the "SEO" tab above the editor. If a slug had been entered
it replaces the page URL generated by CMSimple_XH. Page slugs affect only the page
for which they are defined, but not subpages.
Furthermore, page slugs don't reflect the menu level of the page, and thus can also
be used to provide nicely looking short URLs. Anyhow, make sure that the <em>slugs
of all pages are unique.</em> Otherwise the navigation won't work as expected.
<section id="usage-headings">
<h3>Heading Structure</h3>
@@ -12,7 +12,7 @@ section {
clear: both;

p {
p, li {
text-align: justify;

@@ -8,11 +8,17 @@
if ($plugin_cf['seo']['canonical_enable']) {
$hjs .= seo_canonical();
if (function_exists('seo_slugs')) {
if (defined('XH_ADM') && XH_ADM) {
if (function_exists('XH_registerStandardPluginMenuItems')) {
if (function_exists('seo_slugs')) {
$pd_router->add_tab($plugin_tx['seo']['label_tab'], $pth['folder']['plugin'] . 'seo_tab.php');
if ($edit && $s > -1) {
if ($plugin_cf['seo']['check_page_headings']) {
seo_check_heading_structure($l, 1, 'message_page_headings');
@@ -2,6 +2,9 @@
$plugin_tx['seo']['message_page_headings']="Found irregular page heading structure: %s!";
$plugin_tx['seo']['message_internal_headings']="Found irregular page internal heading structure: %s!";
$plugin_tx['seo']['cf_check_page_headings']="Whether to check the site's page heading structure. In case of an irregular structure, a warning will be shown.";
$plugin_tx['seo']['cf_check_internal_headings']="Whether to check the current page's internal heading structure. In case of an irregular structure, a warning will be shown.";
$plugin_tx['seo']['cf_redir_enable']="Whether the other settings in this group are enabled.";
@@ -0,0 +1,20 @@
function seo_tab($page)
global $sn, $su, $plugin_tx;
$ptx = $plugin_tx['seo'];
$action = XH_hsc("$sn?$su");
$slug = XH_hsc($page['seo_slug']);
return <<<HTML
<form action="$action" method="post">
<label for="seo_slug">{$ptx['label_slug']}</label><br>
<input type="text" id="seo_slug" name="seo_slug" size="50" value="$slug">
<input type="hidden" name="save_page_data">
<div style="text-align: right">
<input type="submit" value="{$ptx['label_save']}">
@@ -0,0 +1,23 @@
function seo_slugs()
global $su, $u, $s, $cl, $pd_router;
for ($i = 0; $i < $cl; $i++) {
$pageData = $pd_router->find_page($i);
if (isset($pageData['seo_slug'])) {
$slug = trim($pageData['seo_slug']);
if ($slug != '') {
$u[$i] = $slug;
if ($su == $slug) {
$s = $i;
} elseif ($i == $s) {
$su = $slug;

0 comments on commit e6f381a

Please sign in to comment.