Skip to content

Commit

Permalink
Implement page slugs
Browse files Browse the repository at this point in the history
Closes #3.
  • Loading branch information
cmb69 committed Nov 21, 2016
1 parent 33ae514 commit e6f381a
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
28 changes: 28 additions & 0 deletions help/help.htm
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ <h2>Installation</h2>
<li>Unzip the distribution on your computer.</li> <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>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> <li>Set write permissions to the subdirectories config/ und languages/.</li>
<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>
<!--<li>Browse to Pagemanager's administration (Plugins &rarr; Pagemanager), and <!--<li>Browse to Pagemanager's administration (Plugins &rarr; Pagemanager), and
check if all requirements are fulfilled.</li>--> check if all requirements are fulfilled.</li>-->
</ol> </ol>
Expand Down Expand Up @@ -101,6 +107,28 @@ <h3>Canonical Links</h3>
the configuration option Canonical→Include. the configuration option Canonical→Include.
</p> </p>
</section> </section>
<section id="usage-slugs">
<h3>Page Slugs</h3>
<p>
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
href="http://www.cmsimple-xh.org/wiki/doku.php/pagedata_plugins">Alternative
Heading</a> instead, or you can use Moved_XH to cater to such changes.
</p>
<p>
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.
</p>
<p>
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.
</p>
</section>
<section id="usage-headings"> <section id="usage-headings">
<h3>Heading Structure</h3> <h3>Heading Structure</h3>
<p> <p>
Expand Down
2 changes: 1 addition & 1 deletion help/stylesheet.css
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ section {
clear: both; clear: both;
} }


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


Expand Down
6 changes: 6 additions & 0 deletions index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
if ($plugin_cf['seo']['canonical_enable']) { if ($plugin_cf['seo']['canonical_enable']) {
$hjs .= seo_canonical(); $hjs .= seo_canonical();
} }
if (function_exists('seo_slugs')) {
$pd_router->add_interest('seo_slug');
}


if (defined('XH_ADM') && XH_ADM) { if (defined('XH_ADM') && XH_ADM) {
if (function_exists('XH_registerStandardPluginMenuItems')) { if (function_exists('XH_registerStandardPluginMenuItems')) {
XH_registerStandardPluginMenuItems(false); XH_registerStandardPluginMenuItems(false);
} }
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 ($edit && $s > -1) {
if ($plugin_cf['seo']['check_page_headings']) { if ($plugin_cf['seo']['check_page_headings']) {
seo_check_heading_structure($l, 1, 'message_page_headings'); seo_check_heading_structure($l, 1, 'message_page_headings');
Expand Down
3 changes: 3 additions & 0 deletions languages/en.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


$plugin_tx['seo']['message_page_headings']="Found irregular page heading structure: %s!"; $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']['message_internal_headings']="Found irregular page internal heading structure: %s!";
$plugin_tx['seo']['label_save']="Save";
$plugin_tx['seo']['label_slug']="Slug";
$plugin_tx['seo']['label_tab']="SEO";
$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_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_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."; $plugin_tx['seo']['cf_redir_enable']="Whether the other settings in this group are enabled.";
Expand Down
20 changes: 20 additions & 0 deletions seo_tab.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

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']}">
</div>
</form>
HTML;
}
23 changes: 23 additions & 0 deletions userfuncs.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

seo_slugs();

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.