Skip to content

← Themes and front office

Building a child theme

Customize the front without touching the base theme, so you can update without losing work.

5 slides 4 min read
  1. PrestaShop · Temes

    Building a child theme

    Customize without getting stuck on one version.

    PrestaShop · Themes and front office arlaf.dev
  2. The problem it solves

    Edit the classic theme directly and the next update eats your changes. A child theme inherits from the parent and keeps only your differences.

    PrestaShop · Themes and front office arlaf.dev
  3. Only what you change

    The child theme copies only the files you want to change. The rest resolves from the parent, so it stays light and easy to audit.

    PrestaShop · Themes and front office arlaf.dev
  4. Overriding a template

    To change the footer, copy templates/_partials/footer.tpl into the child and edit it. PrestaShop uses your version and ignores the parent's.

    PrestaShop · Themes and front office arlaf.dev
  5. Good practices

    Few changes, well documented. Override the minimum, prefer hooks over editing templates, and test each update locally.

    PrestaShop · Themes and front office arlaf.dev
Read the full note

Tard o d’hora un client voldrà un front diferent del tema de sèrie. La temptació és editar el tema classic directament; el problema és que la pròxima actualització de PrestaShop t’esborra la feina. La solució neta és un tema fill.

Heretar en lloc de copiar-ho tot

Un tema fill hereta del tema pare (classic, normalment) i només conté els fitxers que vols canviar. Tota la resta es resol des del pare. Així el teu tema es manté petit —fàcil de revisar i de mantenir— i les actualitzacions del pare et segueixen arribant.

Com es fa, en la pràctica

Vols canviar el peu de pàgina? Copies només templates/_partials/footer.tpl dins del tema fill i l’edites allà. PrestaShop carrega la teva versió i ignora la del pare. El mateix amb el CSS: afegeixes els teus estils al fill sense reescriure els del pare.

Disciplina

  • Sobreescriu el mínim indispensable; cada fitxer copiat és deute futur.
  • Hooks abans que plantilles: si pots aconseguir-ho amb un hook o un mòdul, no toquis el .tpl.
  • Prova cada actualització en local abans de portar-la a producció.

Amb aquesta disciplina, el client té el seu disseny i tu pots actualitzar sense por.