PrestaShop Documentation, PrestaShop Tutorials

Prestashop how to add custom link in account footer section

In PrestaShop, adding a custom link to the account footer section involves a few steps. Please note that the steps might vary slightly depending on the version of PrestaShop you are using. Here’s a general guide to adding a custom link to the account footer section:

  1. Create a Custom Module:
    • Go to your PrestaShop admin dashboard.
    • Navigate to “Modules and Services” > “Module Catalog.”
    • Click on “Create a new module” button.
    • Fill in the necessary details like name, version, author, etc.
    • Save the module.
  2. Add a Hook for Footer Section:
    • In your custom module, you’ll need to add a hook for the footer section so that your custom link is displayed there.
    • Open the main module file, typically named yourmodule.php.
    • Find the install() method and add the hook registration code. For example:
      php

 

    • public function install()
      {
      if (!parent::install() ||
      !$this->registerHook('displayFooterAccount')
      ) {
      return false;
      }
      return true;
      }
  • Create the Link Controller:
    • Create a new file named AccountLinkController.php in the /controllers/front/ folder of your module.
    • Inside the AccountLinkController.php, define the controller class and add the necessary logic to handle the link’s behavior. For example:
      php
    • class YourModuleAccountLinkController extends FrontController
      {
      public function initContent()
      {
      parent::initContent();
      // Add your custom logic here if needed.
      // You can redirect to another page or display content directly.
      // For example:
      $this->redirect_after = 'https://your-custom-link.com';
      $this->redirect();
      }
      }
  • Register the Link Controller:
    • Open your main module file (yourmodule.php) again.
    • Inside the install() method or any other appropriate method, register the link controller with the FrontController class. For example:
      php
    • public function install()
      {
      if (!parent::install() ||
      !$this->registerHook('displayFooterAccount') ||
      !$this->registerController('AccountLink')
      ) {
      return false;
      }
      return true;
      }
  • Add the Custom Link in Footer Template:
    • In your module’s main folder, go to /views/templates/hook/.
    • Create a new file named displayFooterAccount.tpl.
    • Inside the displayFooterAccount.tpl, add the HTML code for your custom link. For example:
      html

 

    • <div>
      <a href="{$link->getModuleLink('yourmodule', 'accountlink')}" title="Your Custom Link">Your Custom Link</a>
      </div>
  1. Clear PrestaShop Cache:
    • After making these changes, clear your PrestaShop cache so that the new module and changes take effect.

Now, your custom link should appear in the account footer section of your PrestaShop store. When users click on the link, they will be redirected to the specified URL or page, based on the logic you added in the controller.

About zohaibk

We develop useful addons for #E-Commerce and #CRM software to provide extra features.#PrestaShop,#Magento,#SugarCRM,#Vtiger & #Android #apps
View all posts by zohaibk →