Magento 2 - CMS Block redirection to url
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I would like to be able to redirect to a url when the user clicks the category.
I have this menu, with the News category. This category loads a CMS Block:
And only having a script which redirects me to an url:
<script type="application/javascript">
window.location.href = "http://web/blog/news/";
</script>
I have also used:
<meta http-equiv="refresh" content="0; URL='http://web/blog/news/'" />
Basically it redirects fine, but in between it loads the CMS Block, which has the javascript:
And after it does properly redirect to the wanted url.
The issue here is that it shows the CMS Block in between, can I avoid that somehow? Or is there a better way to do it?
The main point here is to be able to create a categories link to this webpage, and so far, creating a block and adding it to the category is what I have comed up to. If necessary I can open de code and do it programatically, but it's not what I'm seeking for due to the clients would like to add more and they are not developers.
magento2 category cms redirect magento-2.1.7
add a comment |Â
up vote
2
down vote
favorite
I would like to be able to redirect to a url when the user clicks the category.
I have this menu, with the News category. This category loads a CMS Block:
And only having a script which redirects me to an url:
<script type="application/javascript">
window.location.href = "http://web/blog/news/";
</script>
I have also used:
<meta http-equiv="refresh" content="0; URL='http://web/blog/news/'" />
Basically it redirects fine, but in between it loads the CMS Block, which has the javascript:
And after it does properly redirect to the wanted url.
The issue here is that it shows the CMS Block in between, can I avoid that somehow? Or is there a better way to do it?
The main point here is to be able to create a categories link to this webpage, and so far, creating a block and adding it to the category is what I have comed up to. If necessary I can open de code and do it programatically, but it's not what I'm seeking for due to the clients would like to add more and they are not developers.
magento2 category cms redirect magento-2.1.7
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I would like to be able to redirect to a url when the user clicks the category.
I have this menu, with the News category. This category loads a CMS Block:
And only having a script which redirects me to an url:
<script type="application/javascript">
window.location.href = "http://web/blog/news/";
</script>
I have also used:
<meta http-equiv="refresh" content="0; URL='http://web/blog/news/'" />
Basically it redirects fine, but in between it loads the CMS Block, which has the javascript:
And after it does properly redirect to the wanted url.
The issue here is that it shows the CMS Block in between, can I avoid that somehow? Or is there a better way to do it?
The main point here is to be able to create a categories link to this webpage, and so far, creating a block and adding it to the category is what I have comed up to. If necessary I can open de code and do it programatically, but it's not what I'm seeking for due to the clients would like to add more and they are not developers.
magento2 category cms redirect magento-2.1.7
I would like to be able to redirect to a url when the user clicks the category.
I have this menu, with the News category. This category loads a CMS Block:
And only having a script which redirects me to an url:
<script type="application/javascript">
window.location.href = "http://web/blog/news/";
</script>
I have also used:
<meta http-equiv="refresh" content="0; URL='http://web/blog/news/'" />
Basically it redirects fine, but in between it loads the CMS Block, which has the javascript:
And after it does properly redirect to the wanted url.
The issue here is that it shows the CMS Block in between, can I avoid that somehow? Or is there a better way to do it?
The main point here is to be able to create a categories link to this webpage, and so far, creating a block and adding it to the category is what I have comed up to. If necessary I can open de code and do it programatically, but it's not what I'm seeking for due to the clients would like to add more and they are not developers.
magento2 category cms redirect magento-2.1.7
magento2 category cms redirect magento-2.1.7
asked 2 hours ago


Raül
48313
48313
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago
add a comment |Â
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
You don't have to build an extension for this.
You can do the following:
- Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".
- Go to Marketing -> SEO and sales -> URL Rewrite and change the target path to the desired one. For example: "blog/news". NOTE: If your not allowed to change the target path, delete them and create it again with the correct target path or change it on Database, inside url_rewrite table.
After that, reindex.
add a comment |Â
up vote
2
down vote
For this requirement, you have to build an extension
- which extension will create a category an Attribute and where
your clients add respect cms page URL. How to create a category attribute follow Magento devdoc. - Then using
catalog_controller_category_init_after
event, you will
direct to that custom attribute field value
File: Namespace/Module/Setup/InstallData.php
<?php
namespace NamespaceModuleSetup;Setup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
class InstallData implements MagentoFrameworkSetupInstallDataInterface
protected $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
$this->eavSetupFactory = $eavSetupFactory;
public function install(MagentoFrameworkSetupModuleDataSetupInterface $setup,
MagentoFrameworkSetupModuleContextInterface $context)
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'cms_url', [
'type' => 'varchar',
'label' => 'Your Category Attribute Name',
'input' => 'text',
'visible' => true,
'required' => false,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You don't have to build an extension for this.
You can do the following:
- Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".
- Go to Marketing -> SEO and sales -> URL Rewrite and change the target path to the desired one. For example: "blog/news". NOTE: If your not allowed to change the target path, delete them and create it again with the correct target path or change it on Database, inside url_rewrite table.
After that, reindex.
add a comment |Â
up vote
2
down vote
accepted
You don't have to build an extension for this.
You can do the following:
- Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".
- Go to Marketing -> SEO and sales -> URL Rewrite and change the target path to the desired one. For example: "blog/news". NOTE: If your not allowed to change the target path, delete them and create it again with the correct target path or change it on Database, inside url_rewrite table.
After that, reindex.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You don't have to build an extension for this.
You can do the following:
- Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".
- Go to Marketing -> SEO and sales -> URL Rewrite and change the target path to the desired one. For example: "blog/news". NOTE: If your not allowed to change the target path, delete them and create it again with the correct target path or change it on Database, inside url_rewrite table.
After that, reindex.
You don't have to build an extension for this.
You can do the following:
- Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".
- Go to Marketing -> SEO and sales -> URL Rewrite and change the target path to the desired one. For example: "blog/news". NOTE: If your not allowed to change the target path, delete them and create it again with the correct target path or change it on Database, inside url_rewrite table.
After that, reindex.
answered 22 mins ago
Amir
1114
1114
add a comment |Â
add a comment |Â
up vote
2
down vote
For this requirement, you have to build an extension
- which extension will create a category an Attribute and where
your clients add respect cms page URL. How to create a category attribute follow Magento devdoc. - Then using
catalog_controller_category_init_after
event, you will
direct to that custom attribute field value
File: Namespace/Module/Setup/InstallData.php
<?php
namespace NamespaceModuleSetup;Setup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
class InstallData implements MagentoFrameworkSetupInstallDataInterface
protected $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
$this->eavSetupFactory = $eavSetupFactory;
public function install(MagentoFrameworkSetupModuleDataSetupInterface $setup,
MagentoFrameworkSetupModuleContextInterface $context)
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'cms_url', [
'type' => 'varchar',
'label' => 'Your Category Attribute Name',
'input' => 'text',
'visible' => true,
'required' => false,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
add a comment |Â
up vote
2
down vote
For this requirement, you have to build an extension
- which extension will create a category an Attribute and where
your clients add respect cms page URL. How to create a category attribute follow Magento devdoc. - Then using
catalog_controller_category_init_after
event, you will
direct to that custom attribute field value
File: Namespace/Module/Setup/InstallData.php
<?php
namespace NamespaceModuleSetup;Setup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
class InstallData implements MagentoFrameworkSetupInstallDataInterface
protected $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
$this->eavSetupFactory = $eavSetupFactory;
public function install(MagentoFrameworkSetupModuleDataSetupInterface $setup,
MagentoFrameworkSetupModuleContextInterface $context)
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'cms_url', [
'type' => 'varchar',
'label' => 'Your Category Attribute Name',
'input' => 'text',
'visible' => true,
'required' => false,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
add a comment |Â
up vote
2
down vote
up vote
2
down vote
For this requirement, you have to build an extension
- which extension will create a category an Attribute and where
your clients add respect cms page URL. How to create a category attribute follow Magento devdoc. - Then using
catalog_controller_category_init_after
event, you will
direct to that custom attribute field value
File: Namespace/Module/Setup/InstallData.php
<?php
namespace NamespaceModuleSetup;Setup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
class InstallData implements MagentoFrameworkSetupInstallDataInterface
protected $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
$this->eavSetupFactory = $eavSetupFactory;
public function install(MagentoFrameworkSetupModuleDataSetupInterface $setup,
MagentoFrameworkSetupModuleContextInterface $context)
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'cms_url', [
'type' => 'varchar',
'label' => 'Your Category Attribute Name',
'input' => 'text',
'visible' => true,
'required' => false,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
For this requirement, you have to build an extension
- which extension will create a category an Attribute and where
your clients add respect cms page URL. How to create a category attribute follow Magento devdoc. - Then using
catalog_controller_category_init_after
event, you will
direct to that custom attribute field value
File: Namespace/Module/Setup/InstallData.php
<?php
namespace NamespaceModuleSetup;Setup;
use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;
class InstallData implements MagentoFrameworkSetupInstallDataInterface
protected $eavSetupFactory;
public function __construct(EavSetupFactory $eavSetupFactory)
$this->eavSetupFactory = $eavSetupFactory;
public function install(MagentoFrameworkSetupModuleDataSetupInterface $setup,
MagentoFrameworkSetupModuleContextInterface $context)
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'cms_url', [
'type' => 'varchar',
'label' => 'Your Category Attribute Name',
'input' => 'text',
'visible' => true,
'required' => false,
'global' => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
'group' => 'General Information',
]);
edited 1 hour ago
answered 2 hours ago


Amit Bera♦
54.4k1366158
54.4k1366158
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f244052%2fmagento-2-cms-block-redirection-to-url%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You want custom redirection when an user click on this cateory link it goes to a cms page?
– Amit Bera♦
2 hours ago
Yes basically yes, but as I said, if is possible to do it through backend that would be much better than programatically. Thanks :D
– Raül
2 hours ago