This is a comment on Disable page versioning in permalink, posted by WikiAdmin at 06/28/2026 06:44
View source for Re: Disable page versioning in permalink
I created a hashlink action. It uses the hashid permalink and automatically displays the page title.
%%(php)
<?php
if (!defined('IN_WACKO'))
{
exit;
}
/*
USAGE:
{{hashlink id="QmdteTNEaOo"}}
{{hashlink id="QmdteTNEaOo" text="Custom Title"}}
Output:
<a href="/QmdteTNEaOo">Page Title</a>
*/
if (empty($id))
{
return;
}
$id = trim($id);
try
{
$hashids = new \Hashids\Hashids($this->db->hashid_seed);
$ids = $hashids->decode($id);
}
catch (\Throwable $e)
{
echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
return;
}
if (!is_array($ids) || count($ids) < 3)
{
echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
return;
}
$page_id = (int) $ids[0];
$version_id = (int) $ids[1];
$check = (int) $ids[2];
sscanf(hash('sha1', $page_id . $this->db->hashid_seed . $version_id), '%7x', $expected_check);
if ($check !== (int) $expected_check)
{
echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
return;
}
// get page title
$page = $this->db->load_single(
"SELECT page_id, tag, title " .
"FROM " . $this->prefix . "page " .
"WHERE page_id = " . $page_id . " " .
"LIMIT 1"
);
if (!$page)
{
echo htmlspecialchars($id, ENT_QUOTES, 'UTF-8');
return;
}
// link text
if (!empty($text))
{
$link_text = $text;
}
else if (!empty($page['title']))
{
$link_text = $page['title'];
}
else
{
$link_text = $page['tag'];
}
// permalink URL
$url = $this->href('', $id, '', '', '', false);
echo '<a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '">' .
htmlspecialchars($link_text, ENT_QUOTES, 'UTF-8') .
'</a>';
%%