Jump to content

Undefined variable previewUrl when trying to add html code to cms page


cherrycoding

Recommended Posts

Hi Guys, 

I have a strange problem if I add some simple html code (some divs and a link) I get this error on save:

Notice: Undefined variable: previewUrl

Symfony\Component\Debug\Exception\ContextErrorException

in src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php (line 299)

            [

                'cmsPageForm' => $form->createView(),

                'cmsCategoryParentId' => $request->get('id_cms_category'),

                'enableSidebar' => true,

                'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),

                'previewUrl' => $previewUrl,

                'cmsUrl' => $this->get('prestashop.adapter.shop.url.cms_provider')

                ->getUrl($cmsPageId, '{friendy-url}'),

            ]

        );

    }

If I delete this code I can save the page.

Does anybody have an idea about the issue?

Thanks

Regards, Alex

Link to comment
Share on other sites

  • 1 month later...

I have the same trouble:

CRITICAL php Undefined variable: previewUrl

CRITICAL request Uncaught PHP Exception Symfony\Component\Debug\Exception\ContextErrorException: "Notice: Undefined variable: previewUrl" at /var/www/dev-toshiba/src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php line 299

Link to comment
Share on other sites

  • 3 months later...

Solved, the problem is in the ps_cms table, upgrade

updating from old versions of prestashop, the table is not updated correctly, the indexation column is missing and there is an additional id_shop column

fixing the table everything works.

  • Like 1
Link to comment
Share on other sites

8 hours ago, Gipielle said:

Solved, the problem is in the ps_cms table, upgrade

updating from old versions of prestashop, the table is not updated correctly, the indexation column is missing and there is an additional id_shop column

fixing the table everything works.

Thanks, but my table is correct

Link to comment
Share on other sites

On 3/10/2020 at 12:36 PM, Gipielle said:

Check other ps_cms tables, comparing them to a clean version of prestashop.

I have a clean version of Prestashop 1.7.6.3. I have not updated

 

Solved

src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php

Taken out of the try construct

/** @var EditableCmsPage $editableCmsPage */ 

$editableCmsPage = $this->getQueryBus()->handle(new GetCmsPageForEditing($cmsPageId)); 

$previewUrl = $editableCmsPage->getPreviewUrl();

 

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

  • 4 weeks later...

Hi,

I've you tried, in General settings to :
- switch ON "Allow iFrames" ?
- switch OFF "Use HTMLPurifier library" ?

And disable debug mode on Performances page.

For me it works on PS 1.7.6.4.

Move previous code out try construct was giving me following:

Quote

An unexpected error has occurred. [PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException code 0]


 

Link to comment
Share on other sites

  • 5 months later...
On 3/11/2020 at 11:14 AM, rewuxiin said:

I have a clean version of Prestashop 1.7.6.3. I have not updated

 

Solved

src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php

Taken out of the try construct


/** @var EditableCmsPage $editableCmsPage */ 

$editableCmsPage = $this->getQueryBus()->handle(new GetCmsPageForEditing($cmsPageId)); 

$previewUrl = $editableCmsPage->getPreviewUrl();

 

Life saver ! Thanks

Link to comment
Share on other sites

  • 7 months later...

This is my error, can you help me?

 

CRITICAL
php Uncaught Notice: Undefined variable: cmsPageCategoryForm

CRITICAL
request Uncaught PHP Exception SymfonyComponentDebugExceptionContextErrorException: "Notice: Undefined variable: cmsPageCategoryForm" at /public_html/src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php line 404

Corrisponding at:

'cmsPageCategoryForm' => $cmsPageCategoryForm->createView(),

 

Thanks all of you who help me

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