Jump to content

Forgot password page - Undefined index: notifications


benw

Recommended Posts

With the Starter theme, the Customer "forgot password" page is giving an error:

 

ContextErrorException in smarty_internal_templatebase.php(157) : eval()'d code line 432:
Notice: Undefined index: notifications

But the error does not happen in the Classic theme, and I can't see the difference - maybe I'm missing something?

 
In "/controllers/front/PasswordController.php", the display() function does NOT pass any notifications to the template:
    public function display()
    {
        $this->context->smarty->assign(
            array(
                'layout' => $this->getLayout(),
                'stylesheets' => $this->getStylesheets(),
                'javascript' => $this->getJavascript(),
                'js_custom_vars' => Media::getJsDef(),
                'errors' => $this->getErrors(),
                'successes' => $this->getSuccesses(),
            )
        );

        $this->smartyOutputContent($this->template);
        return true;
    }

If I add the notifcations key myself (like in other display functions), then it fixes the error - but I don't want to edit core code, and why doesn't the error happen in the Classic theme?

'notifications' => $this->prepareNotifications()
Link to comment
Share on other sites

Solved it.

 

The Classic theme checks whether the variable is set in the template, so I had to copy that to the Starter theme:

 

{theme}/templates/_partials/notifications.tpl

{if isset($notifications)}
   {* template code *}
{/if}
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

  • 5 months later...
  • 4 months later...

Here is the solution I adopted for this specific page (all other controllers use notifications).

In a custom module I hooked on "displayHeader" with the following code :

if (Context::getContext()->controller->php_self === "password") {
	$this->context->smarty->assign(array(
		'notifications' => array(
			'error' => Context::getContext()->controller->errors,
			'warning' => Context::getContext()->controller->warning,
			'success' => Context::getContext()->controller->success,
			'info' => Context::getContext()->controller->info,
		)
	));
}

A dirty hack but less dirty than the original code from Prestashop (we are used to it...)

Edited by Florian Lemaitre (see edit history)
Link to comment
Share on other sites

  • 1 year later...
On 3/27/2018 at 3:56 PM, Florian Lemaitre said:

Here is the solution I adopted for this specific page (all other controllers use notifications).

In a custom module I hooked on "displayHeader" with the following code :


if (Context::getContext()->controller->php_self === "password") {
	$this->context->smarty->assign(array(
		'notifications' => array(
			'error' => Context::getContext()->controller->errors,
			'warning' => Context::getContext()->controller->warning,
			'success' => Context::getContext()->controller->success,
			'info' => Context::getContext()->controller->info,
		)
	));
}

A dirty hack but less dirty than the original code from Prestashop (we are used to it...)

Thank you so much i solved with your solution!

 

 

 

Link to comment
Share on other sites

On 5/4/2017 at 12:09 PM, benw said:

Solved it.

 

The Classic theme checks whether the variable is set in the template, so I had to copy that to the Starter theme:

 

{theme}/templates/_partials/notifications.tpl


{if isset($notifications)}
   {* template code *}
{/if}

i tried with this ... but if the notifications is not setting and the template code will not print on my page .... the problem still exist. 

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...