Open modwebpl opened 5 years ago
I would like to see a solution for it too. Anyone? :)
Well.. I know it should be something like this in .htaccess: RweriteRule ^ /([^/.]+)/([0-9])/?$ index.php?q=$1&page=$2 [L] or even RweriteRule ^ /([^/.]+)/([0-9])/?$ index.php?page_start=$1 [L]
Unfortunately it doesn't works and i don't know how to set properly $_GET request for back-end should be :/
Little "ugly hack" in javascript to change pagination url:
export class fixPaginateUrl { constructor(){ this.init(); }
init () { if (!this._setVars()) return; this._setEvents(); }
_setVars() { let _this = this;
_this._url = window.location.href;
if (!_this._url.includes('?')) return false;
_this._pag = document.getElementById('paginate');
if (!_this._pag) return false;
_this._num = _this._pag.querySelector('li.act');
if (!_this._num) return false;
_this._link = _this._url.split('?');
_this._splitNum = _this._url.split('=');
return true;
}
_setEvents() { history.replaceState({id: 'newPage'}, document.title, '${this._link[0]}/${this._num.innerText}'); } }
export class mainPageRedirect { constructor(perPage = 0) { this.init(perPage); }
init(perPage) { if (!this._setVars(perPage)) return; this._setEvents(); }
_setVars(perPage) { let _this = this;
_this._main = document.getElementById('mainPage');
if (!this._main) return false;
_this._host = window.location.hostname;
_this._url = window.location.pathname;
_this._link = this._url.split('/');
_this._perPage = perPage;
if ( parseInt(this._perPage) < 2 ) return false;
if (this._link.length < 3) return window.location.href = this._host;
_this._path = this._link[1];
_this._index = parseInt(this._link[2]) - 1;
return true;
}
_setEvents() { this._index >= 1 ? window.location.href = '${this._host}/${this._path}?page_start=${this._index * this._perPage}' : window.location.href = '${this._host}/${this._path}'; } }
import {fixPaginateUrl} from './fixPaginateUrl.js'; import {mainPageRedirect} from './mainPageRedirect.js';
Hello, i fix URL from back-end like this:
$tpl_id = $modx->documentObject['template']; // template id which has "ditto" or "docLister" with pagination
if($_GET['start'] && $tpl_id == 5) { $cat = $_GET['q']; $page = $_GET['art_start'] / 6 + 1; return ''; }
$req = explode('/', $_SERVER['REQUEST_URI']);
if(count($req) == 3) { $cat = $req[1]; $id = $req[2]; }
$i = 0; foreach (range(0, 999, 6) as $number) { $i++; if($i == $id) { $page = $number; break; } }
if (is_numeric($id) && count($req) >= 3) { header('Location: /'.$cat.'?start='.$page, true, 303); die(); }
enjoy :)
Does anyone know how change rewrite rules in .htaccess to change ugly paginate url for example this: /category?page_start=6 into: /category/6 ?
My client has problem with that :(
Thanks a lot for help.