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:
<?php //preg_test
$source = "this is some html in unformatted format with a <a href=\"directory/link.php?parameter1=parameter1value¶meter2=parameter2value\">link</a>";
echo htmlspecialchars($source),"
";
$source = preg_replace("/(a href=\")([^\"]+)(\")/", "'$1'.'str_replace(array('&','?','+','='),'/','$2')'.'$3'", $source);
echo htmlspecialchars($source),"
";
$samplestring = "astring";
echo "now here's a simple astring replacement just to make sure I'm doing that part right..
";
echo $samplestring," becomes ";
echo str_replace(array('a','s','t','r','i','n','g'),"s",$samplestring);
?>
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.