PrestaShop 1.7后台客户信息显示‘hobbies’字段方法求助
Hey there! Since you're new to PrestaShop 1.7, let's walk through exactly how to get that 'hobbies' field (which maps to the phone number) showing up alongside other customer details in the back office. I've been there struggling to find the right files as a beginner, so let's break this down step by step:
First, head to your PrestaShop installation's back office template directory. The file you need to edit lives here:
/admin-dev/themes/default/template/customers/tabs/customer_information.tpl
Note: If you renamed your admin folder during setup (a smart security move!), replace admin-dev with your custom admin directory name.
Open that customer_information.tpl file in a code editor (like VS Code or Sublime). Look for the section where other contact/info fields are rendered—you'll see blocks of Smarty code that look like this (for the phone number, for example):
<div class="form-group"> <label class="control-label col-lg-3">{$l->s('Phone')}</label> <div class="col-lg-8"> <p class="form-control-static">{$customer->phone|escape:'htmlall':'UTF-8'}</p> </div> </div>
Now insert your 'hobbies' field right next to these existing blocks. The exact code depends on how you set up the 'hobbies' field:
- If you added 'hobbies' directly to the
ps_customerdatabase table:
Add this code block (adjust the label text if you want to call it something else):<div class="form-group"> <label class="control-label col-lg-3">{$l->s('Hobbies')}</label> <div class="col-lg-8"> <p class="form-control-static">{$customer->hobbies|escape:'htmlall':'UTF-8'}</p> </div> </div> - If you used PrestaShop's native Custom Fields feature (Customers > Customer Fields):
You'll need to fetch the value using the custom field helper. Replace the variable line in the block above with:<p class="form-control-static">{$customer->getCustomFieldValue('hobbies')|escape:'htmlall':'UTF-8'}</p>
Save the file, then jump back to your PrestaShop back office. Open any customer's details page—your 'Hobbies' field should now show up alongside the other customer information fields!
Quick beginner pro tip
To avoid losing your changes when you update PrestaShop, don't edit the default back office theme directly. Instead, create a child theme:
- Make a new folder at
/admin-dev/themes/default-child/ - Copy the
customer_information.tplfile into the same directory structure inside the child theme:/admin-dev/themes/default-child/template/customers/tabs/customer_information.tpl - Go to Back Office > Advanced Parameters > Administration and select your new
default-childtheme from the "Back office theme" dropdown. - Make all your edits in the child theme's file instead.
内容的提问来源于stack exchange,提问作者H_Hmd

