Jump to content

How can i display the customers name in other pages?


thomasand

Recommended Posts

box.session.php display the customer name this way {$CUSTOMER.first_name} {$CUSTOMER.last_name}...

content.profile.php use {$USER.first_name} ...

if i want to use any of those in, for example, content.account.php something like <h2>Wecolme {$USER.title}</h2> doesnt work

how can i make the data available for other pages?

Link to comment
Share on other sites

Welcome thomasand! Glad to see you made it to the forums.

Unfortuntaely, there is no guaranteed array of information that is made available to the skin template rendering engine.

On the other hand, there is data that are routinely made available only because it is coded that way and makes sense. One such array of data would be the language pack.

As CubeCart works through the various things it does in preparing a page to display, the various parts of the page are built and rendered one at a time. This is as opposed to giving the template rendering engine all the data, then rendering all the page parts as the last thing to do.

The ramifications are this: page sections built first do not have access to data made available later.

For example, the Account page area is built first. The template makes no use of any customer identifying data. Therefore, the controller code makes no attempt at giving the template any customer related data. To verify this, edit the template content.account.php by adding {debug} at the very end. When next viewing this page, there will be a popup that lists all the variables that are available to this template at the time the template was rendered. (You can close the popup now.)

Now, edit the template main.php by adding {debug} at the very end. Again call for the Account page.

There will be two popups (one absolutely directly on top of the other) - one for each template. For the main.php popup, you see that there is a $CUSTOMER array. The $CUSTOMER array was given to the template rendering engine by the controller code when the "session" area of the page was being rendered, and that data remains available to every template rendered afterwards, including the main template (the last template to be rendered).

To summarize, the data about the customer is not available to the Account area of the page because the template rendering engine does not have that data as yet. And when the template has been rendered, that's it.

What needs to happen is to use a hook to get the data about the logged in customer and give it to the template rendering engine as soon as possible. That data is now available to any template not already rendered.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...