Hacktor Posted May 13, 2011 Share Posted May 13, 2011 Who can help me with this?This is my PHP-script: function hookExtraLeft($params) { global $cookie, $link, $smarty; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLink = $link->getProductLink($product); $smarty->assign('this_path', $this->_path); return $this->display(__FILE__, 'product_page.tpl'); } and this is my .tpl page: {l s='Email dit artikel aan vriend(in)' mod='sendtoafriend'} when je execute this you wil get:http://www.tweewielersite.nl/tweewielersite/modules/sendtoafriend/sendtoafriend-form.php?id_product=102BUT it has to be:http://www.tweewielersite.nl/tweewielersite/modules/sendtoafriend/sendtoafriend-form.php?id_product=102-sparta-e-motion-damesfiets.htmlThe script must not give the id_product code but a friendly URL code.Who can solve this problem for me please...Thanks... :cheese: Link to comment Share on other sites More sharing options...
Hacktor Posted May 13, 2011 Author Share Posted May 13, 2011 Nope, thats not what I want. I want a modified code and not changing my apache URL rewriting.... Link to comment Share on other sites More sharing options...
Hacktor Posted May 13, 2011 Author Share Posted May 13, 2011 I've modified to code function hookExtraLeft($params) { global $cookie, $link, $smarty; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLinks = $link->getProductLink($product); $productLink = preg_replace("(https?)://*", "", $productLinks); $smarty->assign('productLink',$productLink); $smarty->assign('this_path', $this->_path); return $this->display(__FILE__, 'product_page.tpl'); } {l s='Email dit artikel aan vriend(in)' mod='sendtoafriend'} And it gives now this result:www.tweewielersite.nl/tweewielersite/95-sparta-e-motion-damesfiets.htmlHow can I remove the red part from the URL:www.tweewielersite.nl/tweewielersite/95-sparta-e-motion-damesfiets.htmlI only need this part: 95-sparta-e-motion-damesfiets.htmlCan someone help me with the code please Link to comment Share on other sites More sharing options...
Hacktor Posted May 14, 2011 Author Share Posted May 14, 2011 function hookExtraLeft($params) { global $cookie, $link, $smarty; /* Product informations */ $product = new Product(intval(Tools::getValue('id_product')), false, intval($cookie->id_lang)); $productLink = $link->getProductLink($product->id, $product->link_rewrite); $smarty->assign('productLink', parse_url($productLink,PHP_URL_QUERY)); // $productLink = preg_replace("/[^\/]*$/","",$productLink); $productLink = preg_replace("#^[^:/.]*[:/]+#i","",$productLink); print_r($productLink); $smarty->assign(array( 'this_path' => $this_path, 'product' => $product, 'productLink' => $productLink )); {l s='Email dit artikel aan vriend(in)' mod='sendtoafriend'} Gives as result:http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product='>http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product=http://www.tweewielersite.nl/tweewielersite/102-sparta-e-motion-damesfiets.htmlbut it must be:http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product='>http://www.tweewielersite.nl/tweewielersite/sendtoafriend-form.php?id_product=102-sparta-e-motion-damesfiets.htmlCan someone help me to fix the above preg_replace code please????THX Link to comment Share on other sites More sharing options...
Hacktor Posted May 14, 2011 Author Share Posted May 14, 2011 Problem solved:$productLink = preg_replace("/(http:\/\/)www.tweewielersite.nl\/tweewielersite\/+/i","",$productLink);was the correct code.... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now