Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

SEO URLs using a smarty postfilter & $_SERVER['REQUEST_U

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
unisupuk
Smarty Rookie


Joined: 11 Jan 2007
Posts: 12
Location: Ilfracombe, Devon, England

PostPosted: Thu Mar 29, 2007 12:27 am    Post subject: SEO URLs using a smarty postfilter & $_SERVER['REQUEST_U Reply with quote

Hi all,

I've been working with smarty for some time now, and have found it an excellent and adaptive solution for my needs.

I have written several of my own functions and filters, and am very happy with the results shown, but I had an idea that I wanted to check out and im not sure whether it would be possible.

I would like to write a postfilter that rewrites all the PHP parameters in links (index.php?cpath=3&pageno=1) to SEO friendly versions (index.php/plugins-and-functions/extending-with-plugins.html).

I reckon I could use a postfilter to rewrite the links, and then grap and rewrite the URI parameters back into their original values with a function included at the top of my index.php file.

My only concern is this: I use a smarty function {vmenu} that i wrote to create a dynamic menu based on enabled pages and categories. Would the output of this still be caught by the postfilter or does it only affect strings directly on the .tpl file?

What does everyone else think about this? Im going to give it a go, but if anyone would like to help, or is just interested in my project then feel free to email me at ben <at> unisupuk <dot> com :)
_________________
Aspiring to Inspire...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Thu Mar 29, 2007 1:02 am    Post subject: Reply with quote

Maybe check the wiki. There seem to be two postfilters there that you could get inspiration from/use: http://smarty.incutio.com/?page=SmartyPlugins -- you can also try searching the plugins forum here as there may be some other work already done by someone.

Going at this with a postfilter likely won't help much for dynamic content. I suspect you would need an outputfilter for that. It is worthwhile to note that output filters are run on every (non-cached) invocation of the template whereas postfilters are only run at compile-time.

My only question is: why not use friendly urls to begin with? Make apache do the conversion to whatever internal format you will need. It is probably going to have to do that anyways if you are rewriting in the template, so why make it a double-ended effort?
Back to top
View user's profile Send private message
vain
Smarty Rookie


Joined: 20 May 2006
Posts: 23
Location: Berlin / Germany

PostPosted: Wed May 02, 2007 4:13 am    Post subject: Reply with quote

but let me first say, that i never got the clue, why myself should shorten urls or search-engine-optimize them, when all the really big sites don't do this. it seems that nowadays the webcrawlers and spidermonkeys have learned to handle all that crappy-long url stuff. that brings me to this argument: a shorter url is sometimes more readable to human. and that's it...

mod_rewrite might be comfortable and will suit ur needs if you develop for an apache, but if your application should run on serveral webservers, i would suggest to handle the url in the frontcontroller. this is the same point boots mentioned: begin with friendly url structure and apply them manually in the templates or let rewrite do the job. it's not a job for smarty in my eyes.
Code:

index.php?cpath=3&pageno=1
index.php/3/1
or
index.php/news/showarticle/123
Back to top
View user's profile Send private message Visit poster's website
insideraj
Smarty n00b


Joined: 30 Oct 2007
Posts: 1

PostPosted: Tue Oct 30, 2007 12:29 pm    Post subject: Reply with quote

Quote:
but let me first say, that i never got the clue, why myself should shorten urls or search-engine-optimize them, when all the really big sites don't do this. it seems that nowadays the webcrawlers and spidermonkeys have learned to handle all that crappy-long url stuff. that brings me to this argument: a shorter url is sometimes more readable to human. and that's it...


Shorter urls are not only search engine friendly, but also easy to remember.

Is there any PHP guide on how to create mod rewrites on htaccess ?? Rolling Eyes
_________________
Internet Marketing India SEO India
SEO Company India | SEO Blog


Last edited by insideraj on Sat Dec 22, 2007 2:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
intel352
Smarty Rookie


Joined: 11 Nov 2007
Posts: 5

PostPosted: Sun Nov 11, 2007 1:04 am    Post subject: Reply with quote

If you're looking for a good example of an outputfilter for SEO purposes, as well as htaccess rewrite rules, check out my project for X-Cart:
[url will be included in the following post]

The code is available, license is GPL. I hope this helps Wink

Cheers.
Back to top
View user's profile Send private message
intel352
Smarty Rookie


Joined: 11 Nov 2007
Posts: 5

PostPosted: Sun Nov 11, 2007 1:04 am    Post subject: Reply with quote

You can check it out at:
http://code.google.com/p/x-cart-seo/
Back to top
View user's profile Send private message
DaanK
Smarty Rookie


Joined: 02 May 2006
Posts: 5
Location: /home/daank

PostPosted: Thu Nov 29, 2007 8:52 am    Post subject: Reply with quote

the best way for me to do this is always through an .htaccess file.

Code:

RewriteEngine on
RewriteRule ^/content/([0-9]+)/([0-9a-zA-Z-_]+)\.html$ index.php?act=content&id=$1&page_name=$2&%{QUERY_STRING} [L]

RewriteRule ^/news/([0-9]+)/([0-9a-zA-Z-_]+)\.html$ index.php?act=news&id=$1&page_name=$2&%{QUERY_STRING} [L]


this allows me to create url's like this
http://www.yourdomain.com/content/1552/this-is-my-content-page.html
http://www.yourdomain.com/news/881/news-article-name.html

if wanted io can further explain this Wink
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP