Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-08-29 18:38:19

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

version 0.2 is released. It uses a shiny new callback that is only found in TXP 4.2.0 and up, and the plugin is about 98% more efficient as a result. Hats off to Mr Wetzlmayr.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2009-08-29 19:24:38

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 997
Website

Re: smd_short_url: tiny/canonical URLs

Hoo-hah— excellent!

Offline

#15 2009-09-14 12:26:47

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_short_url: tiny/canonical URLs

Hey!
this plugin is really what I need now
I want to share news and videos articles links on Twitter and there is a limit there for only 140 characters.
so I install the plugin, active it, and now what?
when I try to go to http://www.domain.com/1213 it brings me to the error page.
any idea why?
(my permlink mode is on ‘section/title’)
does I need to insert any tag to my pages or something please?

Offline

#16 2009-09-14 19:26:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

THE BLUE DRAGON wrote:

when I try to go to http://www.domain.com/1213 it brings me to the error page.

You don’t need to do anything besides install and activate the plugin so it should just work. A few questions:

  • Are you using v0.2 of the plugin?
  • Are you using TXP 4.2.0?
  • Do you have any gbp_permanent_links or htaccess rules that might be colliding with the plugin?
  • Are you using any subdomains or multi-site capability?
  • Are there any other plugins that might be getting in the way? (MLP for example)

Please let me know the answers to the above and we might be able to track this down.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#17 2009-09-14 19:43:57

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_short_url: tiny/canonical URLs

Bloke wrote:
  • Are you using v0.2 of the plugin?
  • Are you using TXP 4.2.0?
  • Do you have any gbp_permanent_links or htaccess rules that might be colliding with the plugin?
  • Are you using any subdomains or multi-site capability?
  • Are there any other plugins that might be getting in the way? (MLP for example)

yep v0.2
yep v4.2.0
no gbp_permanent_links or htaccess rules
any subdomains or multi-site capability? mmm…no but it is on Godaddy server if it makes any different
my plugins are: adi_calc | bot_privs | chh_if_data | ebl-image-edit | fpx_image_import | hcg_templates | ied_replacer | jbx_multiple_image_upload | rss_admin_show_adv_opts | rss_auto_excerpt | rss_suparchive | rvm_counter | smd_calendar | smd_countdown | smd_gallery | smd_if | smd_lib | smd_short_url | zem_contact_lang | zem_contact_reborn.

here some Diagnostic info:
Document root: /home/content/f/l/a/******/html
$path_to_site: /home/content/f/l/a/******/html
Textpattern path: /home/content/f/l/a/******/html/textpattern
Permanent link mode: section_title
Temporary directory path: /home/content/f/l/a/******/html/textpattern/tmp
MySQL: 4.1.22-max-log
Locale: en_GB.UTF-8
Server: Apache
PHP Server API: cgi-fcgi
RFC 2616 headers:
Server OS: Linux 2.4.21-53.ELsmp

.htaccess file contents:
————————————
#DirectoryIndex index.php index.html

#Options +FollowSymLinks
#Options -Indexes

<IfModule mod_rewrite.c> RewriteEngine On #RewriteBase /relative/web/path/

RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L]

RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*) index.php

RewriteCond %{HTTP:Authorization} !^$ RewriteRule .* – [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

Offline

#18 2009-09-14 21:02:03

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

THE BLUE DRAGON

Thanks for the detailed diag. Weird: can’t see any reason for it to fail. The plugin works fine on my dev site, though it doesn’t work on my actual stefdawson.com domain — but that’s probably because I have a truckload of custom .htaccess rules. In your case, you’re using a stock .htaccess so it’s not that.

Nothing jumps out at me in your plugin list (btw, rss_admin_show_adv_opts is probably not needed any more) so I really don’t know why it would be giving you a 404. I assume you do have an article ID = 1213?! (that’s a lot of articles…)

Could you please modify the plugin and let me know what you see (mail it to me if you don’t want to reveal the site location here). I’ll think about making debug a bit easier in a future version.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2009-09-14 23:08:30

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_short_url: tiny/canonical URLs

1. I did modify the plugin, and no change it gives me an HTTP 404 Not Found error
2. Thanks deleted rss_admin_show_adv_opts ;)
3. No I don’t have an article id#1213, it was just en example but I do have an article id#810

Offline

#20 2009-09-15 07:31:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

THE BLUE DRAGON wrote:

I did modify the plugin, and no change it gives me an HTTP 404 Not Found error

Ooops, I forgot to add an important line: you need the exit; or you won’t see the output when it redirects! I’ve updated the post above to reflect this. Please try again, sorry.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#21 2009-09-15 07:49:21

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_short_url: tiny/canonical URLs

OK I added the exit; but still no any change at all
O_o

Offline

#22 2009-09-15 08:21:08

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

THE BLUE DRAGON wrote:

OK I added the exit; but still no any change at all

Bizarre. It’s definitely running the plugin OK because you can see the diag output (thanks for the site link).

OK, another test. Please alter the plugin again to get rid of all the dmp and exit; lines we’ve added, then change it so it reads:

$have_id = preg_match($re, $_SERVER['REQUEST_URI'], $m);
	if ($have_id) {
		$id = $m[1];
		$permlink = permlinkurl_id($id);
dmp($permlink);
exit;

That should display the permlink of the article it is trying to redirect to. If that matches the url-title of the article you are expecting, then something is definitely getting in the way somewhere because immediately after that the plugin does the redirect.

Last edited by Bloke (2009-09-15 08:21:59)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#23 2009-09-15 08:30:06

THE BLUE DRAGON
Member
From: Israel
Registered: 2007-11-16
Posts: 605
Website

Re: smd_short_url: tiny/canonical URLs

mmm…sorry still not working here is the change

register_callback('smd_short_url', 'txp_die', 404);
function smd_short_url($event, $step) {
	$urlparts = parse_url(hu);
	$re = '#^'.$urlparts['path'].'([0-9].*)#';
	$have_id = preg_match($re, $_SERVER['REQUEST_URI'], $m);
	if ($have_id) {
		$id = $m[1];
		$permlink = permlinkurl_id($id);
dmp($permlink);
exit;
		if ($permlink) {
			ob_end_clean();
			header("HTTP/1.0 301 Moved Permanently");
			header("Location: $permlink");
			die();
		}
	}
}
function smd_canonical($atts, $thing='') {
	global $pretext;
	extract(lAtts(array(
		'type' => 'link',
	), $atts));
	assert_article();
	$link = hu.$pretext['id'];
	$out = '';
	if ($type=="link") {
		$out = '<link rev="canonical" href="'.$link.'" />';
	} else {
		$out = $link;
	}
	return $out;
}

Offline

#24 2009-09-15 08:51:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,568
Website GitHub

Re: smd_short_url: tiny/canonical URLs

THE BLUE DRAGON wrote:

mmm…sorry still not working

Well it won’t “work” as such with the exit; in it because the plugin then stops the rest of the site rendering! But when I visit your ‘domain.com/number’ page (do a forced CTRL-F5 refresh) I see the correct URL it is trying to forward to.

In other words, the plugin has translated the /number into a real article URL. The next thing it does is simply forward you there using the header() function. Thus, as far as the plugin is concerned it is doing its job properly. After that, other cosmic forces are getting in the way (cache?) to show you the 404 instead of what you expect to see.

Have you any custom error_default or error_404 Pages set up? I’m not sure if that will make any difference because I can’t remember when they’re called in the order of page execution, but since we’ve ruled out htaccess, it might have a bearing on things.

P.S. you can take out the dmp() and exit; calls once you’ve looked at the URLs it has generated, since I’m happy the plugin is doing its job ok, as far as it can.

Last edited by Bloke (2009-09-15 08:53:14)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB