Jump to content

Modificar longitud de nombre de usario en header


Pedro.O

Recommended Posts

@Pedro.O

To modify the username length displayed in the header in the PrestaShop 8 Classic theme, follow these steps:

Step 1: 
Open (or create) a custom JavaScript file to add the custom code. The file is typically located at
File Path: themes/classic/assets/js/custom.js

Step 2:
Paste the following code into the custom.js file

document.addEventListener("DOMContentLoaded", function() {
    // Select the username element in the header
    const userInfo = document.querySelector('#_desktop_user_info .user-info .account');

    if (userInfo) {
        // Clean up whitespace and special characters
        let username = userInfo.textContent.trim().replace(/\n/g, '').replace(//g, '').trim();
          
        userInfo.setAttribute("title", username)
          
        // Trim the username to 10 characters and add "..."
        if (username.length > 10) {
            username = username.substring(0, 10) + '...';
        }

        // Update the displayed username
        userInfo.textContent = username;
    }
})

Step 3:
In your PrestaShop admin panel, go to Advanced Parameters > Performance, and click Clear Cache.

Step 4:
Visit the frontend to confirm that the username length is updated in the header. Review the screenshot for reference if needed.

We hope this solution works for you!

Link to comment
Share on other sites

@Pedro.O

Thank you for your response. To fulfill your requirement, please follow these steps:

Go to your theme directory and locate the ps_customersignin. The tpl file is in this path: themes/classic/modules/ps_customersignin/.

Open the file, and find the following code:

<span class="hidden-sm-down">{$customerName}</span>

Replace it with this updated code:

<span class="hidden-sm-down">{$customerName|truncate:10:"":true}</span>

After making this change, clear the cache and check the front end. This should resolve your issue.

 

  • Like 1
Link to comment
Share on other sites

6 hours ago, WebDesk Solution said:

@Pedro.O

Thank you for your response. To fulfill your requirement, please follow these steps:

Go to your theme directory and locate the ps_customersignin. The tpl file is in this path: themes/classic/modules/ps_customersignin/.

Open the file, and find the following code:

<span class="hidden-sm-down">{$customerName}</span>

Replace it with this updated code:

<span class="hidden-sm-down">{$customerName|truncate:10:"":true}</span>

After making this change, clear the cache and check the front end. This should resolve your issue.

 

Genial, despues de hacer esta modificacion, tal cual indica, he podido solucionar el tema y quedo muy bien.

 

Gracias WebDesk Solution.

Saludos Cordiales.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...