Skip to content

Commit

Permalink
Keep url in main url for an easy reloading.
Browse files Browse the repository at this point in the history
  • Loading branch information
PrestaSafe committed Feb 22, 2024
1 parent fc471e9 commit faf406f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
28 changes: 25 additions & 3 deletions _dev/src/components/Iframe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
})
Expand Down
9 changes: 9 additions & 0 deletions src/Controller/AdminThemeManagerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'),
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit faf406f

Please sign in to comment.