From faf406f4a6dbdfa79fdfd4385b7ec85d0cbc0d30 Mon Sep 17 00:00:00 2001 From: Prestasafe Date: Thu, 22 Feb 2024 12:19:37 +0100 Subject: [PATCH] Keep url in main url for an easy reloading. --- _dev/src/components/Iframe.vue | 28 +++++++++++++++++-- .../AdminThemeManagerController.php | 9 ++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/_dev/src/components/Iframe.vue b/_dev/src/components/Iframe.vue index c79f1cd5..29a4ffad 100644 --- a/_dev/src/components/Iframe.vue +++ b/_dev/src/components/Iframe.vue @@ -57,15 +57,37 @@ emitter.on('highLightBlock', (id_prettyblocks) => { emitter.on('changeUrl', (shop, custom_url = null) => { if(custom_url == null) { + custom_url = shop.current_url iframe.setUrl(shop.current_url) - }else{ - iframe.setUrl(custom_url) } - + iframe.setUrl(custom_url) iframe.setIdLang(shop.id_lang) iframe.setIdShop(shop.id_shop) iframe.constructEvent() iframe.reloadIframe() + // change url dynamicly + let url = ajax_urls.prettyblocks_route_generator; + console.log('prettyblocks_route_generator', url); + fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + endpoint: 'custom', + id: 0, + startup_url: custom_url, + }), + }) + .then(response => response.json()) + .then(data => { + console.log('prettyblocks_route_generator', data); + const location = data.url; + history.pushState({}, "", location); + + }); + + }) diff --git a/src/Controller/AdminThemeManagerController.php b/src/Controller/AdminThemeManagerController.php index fbb02e87..4519e59e 100644 --- a/src/Controller/AdminThemeManagerController.php +++ b/src/Controller/AdminThemeManagerController.php @@ -220,6 +220,9 @@ public function indexAction() case 'cms': $startup_url = $link->getCMSLink((int) \Tools::getValue('id')); break; + case 'custom' : + $startup_url = $startup_url; + break; } } // register .env @@ -257,6 +260,7 @@ public function indexAction() 'block_action_urls' => $blockUrl, 'theme_settings' => $settingsUrls, 'startup_url' => $startup_url, + 'prettyblocks_route_generator' => $this->getSFUrl('prettyblocks_route_generator') ], 'trans_app' => [ 'current_shop' => $translator->trans('Shop in modification', [], 'Modules.Prettyblocks.Admin'), @@ -643,16 +647,21 @@ protected function getLangLink($idLang = null, \Context $context = null, $idShop return \Language::getIsoById($idLang) . '/'; } + /** + * Generate URL for PrettyBlocks + */ public function routeGeneratorAction(Request $request) { $posts = json_decode($request->getContent(), true); $endpoint = $posts['endpoint']; $id = (int) $posts['id']; + $startup_url = $posts['startup_url'] ?? ''; $router = $this->get('router'); $url = $router->generate('admin_prettyblocks', [ 'endpoint' => $endpoint, 'id' => $id, + 'startup_url' => $startup_url ]); return (new JsonResponse())->setData([