Page 1 of 1
freetag & mod_rewrite
Posted: Sun Aug 27, 2006 1:31 pm
by emwede
Hi folks,
there is a quite old (May 2006

Thread on freetag an mod_rewrite (which did not help me).
Actually I can not find a way to point the tag-cloud to anything that is tagged with the very tag on
http://www.modlog.de/.
As the freetag plugin builds the url as
http://www.modlog.de/{name of the tag} I can not even intersect with any mod_rewrite rule.
In the configuration scree I gave it the "Taglink"-Value "
http://www.modlog.de/plugin/tag/", which I expected to produce tagcloud links like
http://www.modlog.de/plugin/tag/{name of the tag} . Though the tagcloud does not use that configured part of the url.
I do not dare to believe, that I have to write a rewrite rule for each and every new tag in my .htaccess.
So the developers of this thing must have thought of a different solution.
Which I do not find (the comments in the php files are rather outdated - Though I'm using 2.62 of freetag I find patches and comments pointing to patches for versions like 2.2 and 2.4 and a "main" s9y-file that uses a variable $smallest, which I do not find in my "main"-s9y-file as well as not in my functions_entries.inc.php where another comment points me to - which I do not want to complain about here, but just mention it to show that I tried hard to do my very best to find out about this plugin but did NOT.)
Anyone out there that may be of assistance?
Thanks and regards
emwede
I'm currently using
Serendipity 1.1-alpha7 (14.8.2006) and PHP 5.1.4-1.dotdeb.3
Re: freetag & mod_rewrite
Posted: Sun Aug 27, 2006 1:33 pm
by garvinhicking
Hi!
The freetag plugin only listens to /plugin/tag/XXX - the URLs can only be configured because some people like to make it point to technorati instead of to their own blog.
You must configure the URL in both the event AND the sidebar plugin.
HTH,
Garvin
Posted: Mon Aug 28, 2006 12:40 pm
by emwede
Ok, that's it, thanks Garvin.
You actualy have to leave away the "http://<url>" stuff within the fields Taglink in the freetag_event-Plugin-Configuration and in the coresponding Sidebar-Plugin-Configuration (writing "/plugin/tag") in both fields solved my problem.
Sorry again for posting english to this forum (I just recognized beeing here, when I already posted the initial thread and found no possibility to move the post).
regards und freundliche Grüße
emwede
Posted: Fri Jun 06, 2008 3:47 pm
by gcz
How can I use the follow taglink:
http://www.domain.com/tag/%tagname%
instead of
http://www.domain.com/plugin/tag/%tagname%
I tried to change the taglink, but this does not work.
Posted: Sat Jun 07, 2008 10:49 am
by garvinhicking
Hi!
Sadly this is not supported by the plugin; you could only try to test this with custom rewrite rules...
Regards,
Garvin
Posted: Thu Sep 25, 2008 4:35 pm
by jnsen
Hi,
I tried setting both Taglinks to
http://www.domain.com/tag/%tagname%, and adding the following rewrite rule:
Code: Select all
RewriteRule ^tag/(.*) plugin/tag/$1
but it still does't work.
Does anybody have a different solution?
Posted: Thu Sep 25, 2008 5:12 pm
by jnsen
or would it maybe be easier to make it listen to the "tag" part of the url, instead of the "plugin" part?
can something be done here, perhaps (line 1593, plugin_api.inc.php):
Code: Select all
function event_hook($event, &$bag, &$eventData, $addData = null)
{
// Define event hooks here, if you want you plugin to execute those instead of being a sidebar item.
// Look at external plugins 'serendipity_event_mailer' or 'serendipity_event_weblogping' for usage.
// Currently available events:
// backend_publish [after insertion of a new article in your s9y-backend]
// backend_display [after displaying an article in your s9y-backend]
// frontend_display [before displaying an article in your s9y-frontend]
// frontend_comment [after displaying the "enter comment" dialog]
return true;
}
Posted: Thu Sep 25, 2008 7:46 pm
by garvinhicking
Hi!
Sadly listening to "tag" is not possible; the "plugin" part is required so that s9y can forward a URL to an event plugin. Everything else is not forwarded to a plugin.
This might also be the reason why changing the tagurl allone does not suffice. You would need to create a rewrite rule or custom PHP script that modifies your $_SERVER['REQUEST_URI'], like a [R] full redirect inside your .htaccess, or by the custom PHP code.
HTH,
Garvin
Posted: Fri Sep 26, 2008 1:48 pm
by jnsen
We can have a few different solutions then.
A [R] redirection wouldn't work, because it would change the URL displayed in the browser. And the Rewriterule doesn't work either because it doesn't change the original REQUEST_URI, which is used by serendipity.
I tried changing (line 285, functions_permailnks.inc.php):
Code: Select all
$PAT['PLUGIN'] = '@/(' . $serendipity['permalinkPluginPath'] . '|plugin)/(.*)@';
to:
Code: Select all
$PAT['PLUGIN'] = '@/(' . $serendipity['permalinkPluginPath'] . '|plugin|tag)/(.*)@';
and the relative .htaccess rewrite rule, but I get just a blank page and I'm not able to debug that at the moment.
I have in mind two other solutions then, which are "dirtier" but should work: either changing the $uri variable in index.php whenever it encounters a URL like
http://www.mydomain.com/tag/taggy to
http://www.mydomain.com/plugin/tag/taggy, or adding a preg_match rule for @/tag/(.*)@ that would give an "external_plugin" hook_event.
Which one looks better?
Posted: Fri Sep 26, 2008 2:14 pm
by garvinhicking
Hi!
A [R] redirection wouldn't work, because it would change the URL displayed in the browser. And the Rewriterule doesn't work either because it doesn't change the original REQUEST_URI, which is used by serendipity.
Yes, the URL change would be a result, I forgot to clarify this.
and the relative .htaccess rewrite rule, but I get just a blank page and I'm not able to debug that at the moment.
There are more places than just this pattern that check for the external_plugin event hook in index.php I believe.
I'd go for modifying $_SERVER['REQUEST_URI'] in PHP code, yes. This is less redundancy.
Regards,
Garvin
Posted: Fri Sep 26, 2008 2:58 pm
by jnsen
Aaaand, it worked! Thanks Garvin for the support.
To sum it up, if you want the Freetag Plugin to listen to URLs like
www.mydomain.com/tag/taggy, do the following:
1. Change the Taglink variables in both the sidebar and event configuration.
2. Add the following lines of code in the index.php file:
Code: Select all
if (strpos($uri, $serendipity['serendipityHTTPPath']."tag/") !== false) {
$uri = preg_replace("@/tag/@", "/plugin/tag/", $uri);
}
just after
(should be at line 42)
3. enjoy!