Page 1 of 1
Another nitpick with the poll plugin
Posted: Wed Jan 25, 2006 10:16 am
by Ripper^^
Is there somewhere i can find a switch or something in the files themselves to modify so that when you vote in a poll your browser does not refresh to the frontpage.
For example I don't use
the traditional frontpage as the frontpage to my site, however wherever you are in my site, when you vote in a poll that is where your browser is directed for the results.
Optimally it would be nice for the refresh to leave you on whatever page you happen to be on at the time that you vote, but I would settle for it just refreshing to my
more normal frontpage
Thanks in advance for any help.
Ripper^^
Re: Another nitpick with the poll plugin
Posted: Wed Jan 25, 2006 11:29 am
by garvinhicking
Actually this is more a problem of the frontpage detection: The poll form submits to "/index.php?index.php". The reason is that the function tries to get the recent page and append it as an argument to the URL. With mod_rewrite this should work a bit better, I guess.
Anyways - now the frontpage sees that the request is not just "index.php" but "index.php?index.php" and thus thinks, it's not the actual frontpage anymore.
I've just committed a "fix" which does not append "index.php" in case this is the simple URL. You'll need to apply this patch to your include/functions_permalinks.inc.php file:
http://svn.berlios.de/viewcvs/serendipi ... 730&r2=874
Regards,
Garvin
Posted: Thu Jan 26, 2006 7:25 am
by Ripper^^
Thanks a bunch Garvin. Helpful as always, if it wasn't for you and the rest of the helpful people in this forum, Serendipity wouldn't be nearly as nice of an application.
Ripper^^
Posted: Thu Jan 26, 2006 7:43 am
by Ripper^^
ok, i applied that line to the include/functions_permalinks.inc.php file.
however,
http://svn.berlios.de/viewcvs/serendipi ... 730&r2=874
says that should be line 688, in my file it was line number 530, does that matter?
Posted: Thu Jan 26, 2006 7:47 am
by Ripper^^
after testing, the patch did not work, the page still refreshes to index.php?frontpage after voting.
Posted: Thu Jan 26, 2006 12:01 pm
by garvinhicking
Hm, you're right.
I think the s9y frontpage detection of the static page plugin (you do use that to show your custom frontpage, right?) might be wacky there.
Could you look up this code in serendipity_event_staticpage.php:
Code: Select all
$args = implode('/', serendipity_getUriArguments($eventData, true));
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = $this->getStartpage();
}
and modify it to:
Code: Select all
$args = implode('/', serendipity_getUriArguments($eventData, true));
echo "DEBUG ARGS: " . print_r($args, true) . "<br />\n";
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
echo "DEBUG SUBPAGE: " . print_R($serendipity['GET']['subpage'], true) . "<br />\n";
if ((empty($args) || trim($args) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = $this->getStartpage();
}
Those two debug statements should show up in your HTML when submitting the vote to your custom frontpage. Maybe you can tell me what it says for you.
Regards,
Garvin
Posted: Thu Jan 26, 2006 9:42 pm
by Ripper^^
ok, serendipity_event_staticpage.php has been updated accordingly. after voting the page was refreshed not to index.php?frontpage, but to index.php? which brings up index.php?frontpage.
the two debug arguments that show up at the bottom of the page display thusly:
DEBUG ARGS: index.php?
DEBUG SUBPAGE:
Hope that helps you Garvin
Thanks,
Ripper^^
Posted: Fri Jan 27, 2006 11:27 am
by garvinhicking
Could you please modify this part of the code from above:
Code: Select all
trim($args) == $serendipity['indexFile']
to this:
Code: Select all
trim($args, "? \t\n\r\0\x0B") == $serendipity['indexFile']
This should remove the "?" at the end for propper comparison...?
Tell me if it works, then I can commit that.
Regards,
Garvin
Posted: Sat Jan 28, 2006 7:06 am
by Ripper^^
ok, new addition pasted into serendipity_event_staticpage.php.
When voting from the frontpage
http://www.theripper.com/ the URL refreshes to
http://www.theripper.com/index.php? and shows the frontpage it's supposed to, and the debug arguments at the bottom of the page are thus:
DEBUG ARGS: index.php?
DEBUG SUBPAGE:
When voting from another page, the contributors page for example which is at
http://www.theripper.com/index.php?/pag ... utors.html the URL refreshes to
http://www.theripper.com/index.php?&/pa ... utors.html (note the & in the URL) and shows the standard serendipity frontpage which on my site is reached by index.php?frontpage, and the debug arguments at the bottom of the page are thus:
DEBUG ARGS: index.php?&/pages/contributors.html
DEBUG SUBPAGE:
hope this helps,
Ripper^^
p.s. I didn't know if i was supposed to undo the original patch to the include/functions_permalinks.inc.php file, so i did not undo it, but left it patched.
Posted: Sat Jan 28, 2006 9:47 am
by garvinhicking
Thanks to much for staying on board with me
Please again edit the currentURL function in your include/functions_permalinks. Remember the line you inserted there?
Change it from this:
Code: Select all
$uri['path'] = preg_replace('@^' . preg_quote($serendipity['indexFile']) . '@i', '', $uri['path']);
to this:
Code: Select all
$uri['path'] = preg_replace('@^(&)?' . preg_quote($serendipity['indexFile']) . '(&)@i', '', $uri['path']);
Note the two inserted (&)? parts. Those should rid you of the "&pages/contributors" string so that the link detection works again?
Regards,
Garvin
Posted: Sun Jan 29, 2006 2:28 am
by Ripper^^
Works like a charm Garvin, when voting from whatever page, that's the page you stay on.
Posted: Sun Jan 29, 2006 3:06 pm
by garvinhicking
Yeay, cool. I'll commit the change then officially.
Regards,
Garvin