| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
How and where do I use a Smarty Output filter in X-Cart? | |||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
How and where do I use a Smarty Output filter in X-Cart?
I'm building a URL-rewriter for my cart to make it search-engine-friendly. I'm making an outputfilter/plug-in to take care of the actual URL re-writing so I don't have to modify anything other than the templates (hopefully) and then add a small bit of PHP code to all the PHP pages to accept get variables in the format:
name/value/name/value/name/value rather than name=value&name=value&name=value Is there anything anyone can tell me about using Smarty Output Filters? Do I just need to register the output filter once in one of my main templates or do I need to include it just before and explicit Code:
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#2
|
|||||||
|
|||||||
Hi minorgod,
I hope you'll share your rewriter with the forum when you're done! ATKOgirl |
|||||||
#4
|
|||||||||
|
|||||||||
preliminary test results
So far I've managed to build a url rewriter plug-in that finds any urls in the pending Smarty output and fills them with a test URL in the format http://someurl. I've run into a snag doing a sub-expression match/string replacement to replace all the special url parameter delimiters with slashes. I'm a regex newbie and this is damn complicated! Any regex gurus out there that can lend a hand fixing this regex? Here's an example of the test code that isn't working right...
Code:
Hope someone knows what I'm doing wrong here, cuz I don't! I'll be working on this over the weekend so please post if you know the answer. I'll release a small tutorial once I get everything working right (assuming it doesn't require hand-coding on many php pages in which case I may not write a tutorial).
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#5
|
|||||||||
|
|||||||||
Good for testing out regexpr, helped me out on alot of regular expressions in perl:
http://www.savarese.org/oro/demos/OROMatcherDemo.html
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart. |
|||||||||
#6
|
|||||||||
|
|||||||||
I FOUND it!
After over 8 hours of testing various combinations of regular expression syntax, I have managed to get the following to work for changing the URL parameter syntax in a link to use slashes instead of standard URL parameter syntax.....
Code:
Hope this saves someone 8 hours. It turns out that the main stumbling block was the use of the /e flag at the end of the preg pattern. Without that little "e" after the pattern, PHP wouldn't execute the substring search on the 4th substring that contained the parameters needing slash replacement. Now it does. Now on with the search-engine friendly cart mod!
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#7
|
|||||||||
|
|||||||||
disregard that last post
That last post was on the right track, but the final version required much more work. All the bugs still aren't worked out. The module now rewrites all the links on the page using slashes as separators, but now when the page loads, it immediately does a full store search and lists all the items in my store. Not sure why this is happening except that I suspect the search form is being activated by some variable being set when Smarty renders the page the first time, before the output filter has a chance to rewrite the links. Not sure if this is the problem yet. Can anyone think of a reason my customer/home.php would instantly reload with a full store search?
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#8
|
|||||||||
|
|||||||||
Eureka!
Okay, below is a new Smarty Output Filter I wrote to rewrite all the links on a page to be search-engine friendly. HOWEVER, you cannot simply drop this in your Smarty Plug-ins folder and be done. If you rewrite all your page links using this plug-in, then you'll still need to alter your application logic to handle GET varables differently, so you can parse them from the PATH_INFO rather than from the _GET or HTTP_GET_VARS array. Here is the code to make your own Smarty Plug-in....
Code:
Please note, this code is not optimized. A couple of steps here could easily be reduced into a single step, but I needed the extra steps for easier debugging. If you modify this or discover bugs, please post them here. If you need to see the code that is being generated without rendering it in your browser, simply change the last line of this output filter to Code:
Below is a sample PHP script that you might use to grab the variable names and values from the URL on pages where you use this output filter, or target pages you might navigate to from a page using this output filter: Code:
Love me.
__________________
www.brettbrewer.com Getting back into x-cart dev after a long hiatus. Modded lots of x-carts from version 3.1.x to 4.1.x. Developer of ImageScaler mod, Pre-login per user coupon mod, Wordpress feed mod, DigitalSubscriptions mod, Phonetic bulk download keys addon for DownloadExpander mod, Serial Number Generator for ESD products, Custom CMS/LMS integrations, external products mod, and more. |
|||||||||
#10
|
|||||||
|
|||||||
X-Cart: Static Catalog
Actually, the next version of X-Cart will have a "Static Catalog" feature built-in, which will make it more search engine-friendly.
The cart will be able to generate a HTML version of the catalog automatically. All "dynamic" buttons like "Add to cart", "View cart", "Login", etc. will be linked to the standard X-Cart PHP pages. |
|||||||
|
|||
X-Cart forums © 2001-2020
|