Read More
Menu Close

    How to use {url} for links creation on tpl files in Prestashop 1.7

    In this blog, we will learn new standards of links creation on tpl files in Prestashop 1.7 .

    In Prestashop 1.6 we used {$link} variable on tpl files and we created links on tpl files by calling different link creation methods from $link object.

    But in Prestashop 1.7, a new standard has been set to create links on tpl files. Now we will use {url} for different kind of links creation on tpl files in Prestashop 1.7.

    Let’s understand it with some examples to know how to replace {$link} of Prestashop 1.6 with {url} in Prestashop 1.7 –

    Prestashop 1.6 : {$link->getModuleLink()}
    Prestashop 1.7 : {url entity='module' name='myModule' controller='myController' params = ['paramKey1' => $paramValue1, 'paramKey2' => $paramValue2]}
    Example : {url entity='module' name='marketplace' controller='productupdate' params=['edited' => 1, 'id' => $id]}
    
    Prestashop 1.6 : {$link->getPageLink()}
    Prestashop 1.7 : { url entity='myPageName' params = ['paramKey1' => $paramValue1, 'paramKey2' => $paramValue2]}
    Example : { url entity='my-account' params=['edited' => 1, 'id' => $id]}
    
    Prestashop 1.6 : {$link->getCategoryLink()}
    Prestashop 1.7 : {url entity='category' id=$id_category id_lang=$id_lang}
    Example : {url entity='category' id=3 id_lang=2}
    
    Prestashop 1.6 : {$link->getCmsLink()}
    Prestashop 1.7 : {url entity='cms' id=$id_cms id_lang=$id_lang}
    Example : {url entity='cms' id=3 id_lang=2}
    
    Prestashop 1.6 : {$link->getCatImageLink()}
    Prestashop 1.7 : {url entity='categoryImage' id=$id_category name='imageType'}
    Example : {url entity='categoryImage' id=3 name='home-default'}

    Symfony URLs with {url}

    You can also create Symfony URLs using {url} in Prestashop 1.7

    Searching for an experienced
    Prestashop Company ?
    Read More
    //link for admin order view page
    <a href="{url entity='sf' route='admin_orders_view' sf-params=["orderId"=>"$id_order"] }"> Link to admin order page <a/>

    You have to pass

    entity : ‘sf’ for symfony url

    route : name of the symfony route (admin_orders_view) in the route parameter

    sf-params : link parameters for symfony url.

    So this is how you can use {url} in Prestashop 1.7 for links creation in tpl files.

    Note-  {url} is directly linked to the getUrlSmarty($params) in the “classes/Link.php” . So you can check this function for more information on links creations iwth {url}.

    You can also take a reference on this topic by visiting the following link –

    Reference – http://developers.prestashop.com/themes/smarty/helpers.html

    . . .
    Discuss on Helpdesk

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    3 comments

  • Ivan
    Hi

    A third party company holds duplicate data of the products from our Prestashop (1.6) site (they are a kind of comparison site). One of the services they offer is a Datasheet download of the specifications of any given product in PDF format. What I want is a link on each individual product page which, when clicked, will download the PDF in the users browser.

    They’ve given me the following link to place – presumably in the product.tpl file – to enable the facility.

    http://api.3rd-party-website.com/api/DatasheetsPdf?brandNodeId=119288&partNumber={$partNumber}

    Could you advise me how to implement that with Smarty please.

    Thanks

    • Mehul Gupta (Moderator)
      Hi,

      Please raise a ticket at http://support.webkul.com/ so we can discuss the possibility of customizing it for you.

      Thanks & Regards
      Mehul

  • Andrea Testa
    Ty 😉
  • Back to Top