php - Get current page and url in prestashop -


i trying url of current page in prestashop test multiple pages of website if website pages not have consistent pattern. noticed of prestashop pages of form /index.php?id_category=<categoryid>&controller=<controllername>, /index.php?id_product=<productid>&controller=<controllername> etc. able controller name using context::getcontext()->controller->php_self

so, want know how product id or category id form current url of page?

there's no need manually reconstruct link, can use link class.

// context $context = context::getcontext(); // category id (on category , product page) $cid = $context->controller->getcategory()->id; // product id (on product page) $pid = $context->controller->getproduct()->id;  // category link $cat_link = $context->link->getcategorylink($cid); // product link $prod_link = $context->link->getproductlink($pid); 

Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -