Skip to content

Commit

Permalink
Don't include the page URL for the first published page
Browse files Browse the repository at this point in the history
The first published page of a CMSimple_XH installation can be requested
with or without its page URL (unless we're in admin mode).  To avoid DC
we omit the page URL if possible.  We're doing some trickery in
loginlink(), so that the page URL is always passed there – otherwise
we'd get the unpleasant "No page selected" notice.
  • Loading branch information
cmb69 committed Jan 18, 2018
1 parent 6521ae4 commit 8864e33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions cmsimple/functions.php
Expand Up @@ -873,9 +873,9 @@ function XH_findNextPage()
*/
function a($i, $x)
{
global $sn, $u;
global $sn, $u, $xh_publisher;

return isset($u[$i])
return isset($u[$i]) && (XH_ADM || $i !== $xh_publisher->getFirstPublishedPage())
? '<a href="' . $sn . '?' . $u[$i] . $x . '">'
: '<a href="' . $sn . ($x ? '?' . $x : '') . '">';
}
Expand Down Expand Up @@ -2684,9 +2684,13 @@ function XH_getLocatorModel()
*/
function XH_getPageURL($index)
{
global $sn, $u;
global $sn, $u, $xh_publisher;

return $sn . '?' . $u[$index];
if ($index === $xh_publisher->getFirstPublishedPage()) {
return $sn;
} else {
return $sn . '?' . $u[$index];
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions cmsimple/tplfuncs.php
Expand Up @@ -319,10 +319,12 @@ function mailformlink()
*/
function loginlink()
{
global $s, $tx;
global $s, $tx, $xh_publisher, $u;

if (!XH_ADM) {
return a($s > -1 ? $s : 0, '&amp;login" rel="nofollow')
$index = $s > -1 ? $s : 0;
$extra = ($index === $xh_publisher->getFirstPublishedPage() ? $u[$index] : '');
return a($index, $extra . '&amp;login" rel="nofollow')
. $tx['menu']['login'] . '</a>';
}
}
Expand Down

9 comments on commit 8864e33

@olape-git
Copy link

@olape-git olape-git commented on 8864e33 Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, nun muss ich erst mal sehen, wie das hier läuft.
Ich würde in der tplfuncs.php die 326 und 327 nur gegen:
return a($index, '&amp;login" rel="nofollow')
tauschen.

Das , '" rel="prev' aus Zeile 481 löst das ? aus, welches beim Prev-Link auf die erste Seite zu viel ist.
<a href="/Test/?" rel="prev">« vorige Seite</a>
Leider habe ich dazu noch keine Lösung.

@olape-git
Copy link

@olape-git olape-git commented on 8864e33 Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fragezeichen bei Prev-Link auf die erste Seite ist zu viel.
functions.php Zeile 880
: '<a href="' . $sn . ($x ? '?' . $x : '') . '">';
gegen
: '<a href="' . $sn . ($x ? ($x[0] != '"' ? '?' . $x : $x) : '') . '">';

@cmb69
Copy link
Owner Author

@cmb69 cmb69 commented on 8864e33 Jan 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, stimmt. Garstige Sache! Vielleicht sollten wir in previouspage() nicht a() sondern XH_getPageUrl() verwenden? (und vielleicht auch sonst intern darauf umstellen, zumindest wenn der $x parameter von a() trickreich verwendet wird)

@olape-git
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mir fehlt der Überblick, wo a() überall Verwendung findet. Und wenn, wie?
Mit der Änderung funktioniert es erst mal.
Kann ja aber sein, es gibt noch andere Varianten.

@olape-git
Copy link

@olape-git olape-git commented on 8864e33 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tplfuncs.php

481
return a($index, '" rel="prev') . $tx['navigator']['previous'] . '</a>';
gegen
return '<a href="' . XH_getPageURL($index) . '" rel="prev">' . $tx['navigator']['previous'] . '</a>';

498
return a($index, '" rel="next') . $tx['navigator']['next'] . '</a>';
gegen
return '<a href="' . XH_getPageURL($index) . '" rel="next">' . $tx['navigator']['next'] . '</a>';

@frase-git
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wird "nächste Seite" und "vorherige Seite" überhaupt benötigt?
MIR erschienen diese Dinger immer fragwürdig - ich habe sie nie verwendet.

@cmb69
Copy link
Owner Author

@cmb69 cmb69 commented on 8864e33 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wird "nächste Seite" und "vorherige Seite" überhaupt benötigt?

Zumindest können sie in Templates vorhanden sein, und wir können daher die Funktionen nicht einfach entfernen. Es könnte allerdings jemand vorschlagen, diese beiden Funktionen zu missbilligen.

Problematischer sind auf jeden Fall <link rel="prev"> und <link rel="next">, die automatisch im <head> erzeugt werden.

@olape-git
Copy link

@olape-git olape-git commented on 8864e33 Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove prev/next s #285
Aber das ist ja schon im Plan.
Ich nehme sie allerdings jetzt schon immer raus. Im normalen Fall sind die "zweckentfremdet" genutzt.
Kaum einer hat die Seite wirklich so aufgebaut, dass diese Links Sinn machen.
Realblog z.B. müsste diese Links erzeugen innerhalb der eigenen Paginierung, vielleicht sogar auch noch innerhalb der einzelnen Blogs.

@olape-git
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also für mich funktioniert das so, wie es jetzt ist, inkl. der Änderungen für prev und next.
Ich konnte keine Fehler feststellen. Läuft alles wie es soll. Zusammen mit der 301 für die Startseite ein gutes Ergebnis.

Please sign in to comment.