SimplePortal
Customization => Blocks and Modifications => Topic started by: Chen Zhen on May 27, 2013, 12:13:17 AM
-
This block will shorten your forum URL's similar to the Pretty URL's modification but does not require any mod installation or extra files.
Simply create a Custom PHP block and set the following:
- Display Options: Show Block On Everywhere
- Style Options: checkmark... No Title and No Body
Enter the following code for the block:
/*
* Simple URL's v1.1 for Simple Portal
* copyright 2013, 2014 underdog@webdevelop.comli.com
*/
global $boardurl, $context;
$url_array = array();
$new = $boardurl;
$object[0] = 'index';
$action = !empty($context['current_action']) ? '/' . $context['current_action'] : false;
$area = !empty($context['menu_data_1']['current_action']) ? '/' . $context['menu_data_1']['current_action'] : false;
$subaction = !empty($context['current_subaction']) ? '/' . $context['current_subaction'] : false;
$page = !empty($_REQUEST['page']) ? '/' . $_REQUEST['page'] : false;
$game = !empty($_REQUEST['game']) ? '/game=' . (int)$_REQUEST['game'] : 0;
$board = !empty($_REQUEST['board']) ? '/board=' . $_REQUEST['board'] : false;
$topic = !empty($_REQUEST['topic']) ? '/topic=' . $_REQUEST['topic'] : false;
$msg = !empty($_REQUEST['msg']) ? '/msg=' . $_REQUEST['msg'] : false;
$user = !empty($_REQUEST['u']) ? '/user=' . $_REQUEST['u'] : false;
$url = !empty($_SERVER['REQUEST_URL']) ? $_SERVER['REQUEST_URL'] : false;
if (!$msg && strpos($url, 'msg') !== false)
{
$message = array_reverse(explode('msg', $url));
if ((int)$message[0] > 0)
$msg = '.msg' . $message[0] . '#msg' . $message[0];
}
if ($action == '/arcade' && $game)
$new = $boardurl . $game;
elseif ($action || $area || $subaction || $page || $board || $topic || $msg || $user)
{
$url_array = array($action, $area, $subaction, $page, $board, $topic, $msg, $user);
foreach ($url_array as $key => $url)
{
if (!empty($url))
$object = explode('.', $url);
if (strpos($new, $url) === false)
$new .= $url;
}
}
else
$new = $boardurl . '/';
echo '
<script type="text/javascript"><!-- // --><![CDATA[
var stateObj = {foo: "', $object[0],'"};
window.history.pushState(stateObj, "Title", "'.$new.'");
// ]]></script>';
It needs some work as pressing the back link in a browser will not currently work properly for v1.0. If anyone decides to use this please post any issues in this thread and I will attempt to accommodate by adjusting the block code for discrepancies I may have overlooked.
-
woooow great work
-
Sorry to pull up an old thread... I find this mod useful but is there a way the back button would be fixed?
-
Sorry to pull up an old thread... I find this mod useful but is there a way the back button would be fixed?
+1 here as well >_< if possible it would replace that horrible PrettyURLs...