<![CDATA[ Ditto - Pagination and Back to top - My Forums]]> https://forums.modx.com/thread/?thread=42557 <![CDATA[Re: Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246283 aldrin123 Feb 10, 2011, 11:24 PM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246283 <![CDATA[Re: Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246282
Thanks for that. I have sorted the php version issue but the snippet still does not seem to work. There is no error now.

I have created the snippet with your latest version:-

<?php
/*
SelfReference - returns current url preserving all query variables
Copyright (c) 2009-2010 Aleksander Maksymiuk, http://setpro.net.pl/
You can check latest release at
http://setpro.net.pl/software/self-reference#attachments
Revision: January 9, 2009
*/

define(’SITE_START’, ’’);

parse_str(htmlspecialchars_decode($_SERVER[’QUERY_STRING’]), $query_vars);
if (isset($query_vars[’q’])) {
# we are within MODx
$retscript = $query_vars[’q’];
unset($query_vars[’q’]);
} else {
# not MODx (or we are on site’s start), but it has to work anyway
$retscript = $_SERVER[’PHP_SELF’]; /* 1 - it can be resolved in this way or... */
####$retscript = SITE_START; /* 2 - ... in this */
}
if (count($query_vars)) {
$retqstr = ’’;
foreach ($query_vars as $var => $value) {
$retqstr .= ’&amp;’ . $var . ’=’ . htmlspecialchars($value);
}
$retqstr = preg_replace(’/^&amp;/i’, ’’, $retqstr);
return $retscript . ’?’ . $retqstr;
} else {
return $retscript;
}
?>

The page code is as follows:-

<strong>Local Issues</strong>

[[Ditto? &startID=`8` &summarize=`4`&tpl=`news_format` &paginate=`1` &paginateAlwaysShowLinks=`1` SelfReference? &redir=`[+alias+]`]]



Showing <strong>[+start+]</strong> -
<strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles | Page
<strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong>



<div id="ditto_pages"> [+previous+] [+pages+] [+next+] </div>

As you can probably tell I have very limited knowledge on modx and php etc. I still have the same problem in that when I click on a link in the second page it returns the correct page content but with the first page links.

You can see the issue at http://icomlocal.com/index.php?id=8

I am using friendly urls.

I am sure I have not implemented your solution incorrectly but I do not have the knowledge to figure out what I have done wrong.

Cheers

iCOM


]]>
icom Mar 06, 2010, 03:17 AM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246282
<![CDATA[Re: Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246281 Alik Mar 06, 2010, 02:35 AM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246281 <![CDATA[Re: Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246280
This looks like the exact fix I need.

However, I am getting the following error:-

Fatal error: Call to undefined function: htmlspecialchars_decode() in ../manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 7

I am running Evolution 1.0.2

Any ideas?


]]>
icom Mar 06, 2010, 02:26 AM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246280
<![CDATA[Re: Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246279
1) the simplier part:
<a href="[(site_url)][!self_reference!]#topofpage">topofpage</a>
(of course, do not forget to create topofpage anchor ;)
------
2) the gory rest -- "self_reference" snippet
<?php
/*
 Self Reference - returns current url preserving all query variables
 Copyright (c) 2009 Aleksander Maksymiuk, http://setpro.net.pl/
 You can check latest release at
    http://setpro.net.pl/software/self-reference#attachments
*/
parse_str(htmlspecialchars_decode($_SERVER['QUERY_STRING']), $query_vars);
if (isset($query_vars['q'])) {
  # we are within MODx
  $retscript = $query_vars['q'];
  unset($query_vars['q']);
} else {
  # not a MODx (or we are on / page), but it has to work anyway
  $retscript = $_SERVER['PHP_SELF']; /* 1 */
}
if (count($query_vars)) {
  $retqstr = '';
  foreach ($query_vars as $var => $value) {
    $retqstr .= '&' . $var . '=' . htmlspecialchars($value);
  }
  $retqstr = preg_replace('/^&/i', '', $retqstr);
  return $retscript . '?' . $retqstr;
} else {
  return $retscript;
}
?>

The snippet works with either MODx or any other PHP-driven site. If it runs within MODx it takes into account that url may be rewritten with mod_rewrite and behaves properly. If you find it useful, you can use it (please preserve author’s info -- creating the snippet took me a while).]]>
Alik Nov 06, 2009, 11:14 AM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246279
<![CDATA[Ditto - Pagination and Back to top]]> https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246278
We have a back to top link which is designed to go back to the top of the page, however if we go to the next page the back to top link returns to the start page.

How do we make it so that the back to top only returns to the top of the page you are on.]]>
worchyld Nov 06, 2009, 05:43 AM https://forums.modx.com/thread/42557/ditto---pagination-and-back-to-top#dis-post-246278