SimplePortal

Customization => Blocks and Modifications => Topic started by: Chen Zhen on May 27, 2013, 12:13:17 AM

Title: [BLOCK] Simple URL's
Post 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:


Enter the following code for the block:
Code: [Select]
/*
 * 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. 
Title: Re: [BLOCK] Simple URL's
Post by: Sapinho® on May 27, 2013, 02:48:29 AM
woooow great work
Title: Re: [BLOCK] Simple URL's
Post by: RedRobin on May 27, 2014, 01:10:42 AM
Sorry to pull up an old thread... I find this mod useful but is there a way the back button would be fixed?
Title: Re: [BLOCK] Simple URL's
Post by: ♦ Ninja ZX-10RR ♦ on November 29, 2014, 10:53:59 PM
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...
SimplePortal 2.3.8 © 2008-2024, SimplePortal