View previous topic :: View next topic |
Author |
Message |
unisupuk Smarty Rookie
Joined: 11 Jan 2007 Posts: 12 Location: Ilfracombe, Devon, England
|
Posted: Thu Mar 29, 2007 12:27 am Post subject: SEO URLs using a smarty postfilter & $_SERVER['REQUEST_U |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Thu Mar 29, 2007 1:02 am Post subject: |
|
|
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 |
|
vain Smarty Rookie
Joined: 20 May 2006 Posts: 23 Location: Berlin / Germany
|
Posted: Wed May 02, 2007 4:13 am Post subject: |
|
|
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 |
|
insideraj Smarty n00b
Joined: 30 Oct 2007 Posts: 1
|
Posted: Tue Oct 30, 2007 12:29 pm Post subject: |
|
|
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 ?? _________________ 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 |
|
intel352 Smarty Rookie
Joined: 11 Nov 2007 Posts: 5
|
Posted: Sun Nov 11, 2007 1:04 am Post subject: |
|
|
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
Cheers. |
|
Back to top |
|
intel352 Smarty Rookie
Joined: 11 Nov 2007 Posts: 5
|
|
Back to top |
|
DaanK Smarty Rookie
Joined: 02 May 2006 Posts: 5 Location: /home/daank
|
|
Back to top |
|
|