Magento 2 - CMS Block redirection to url

The name of the pictureThe name of the pictureThe name of the pictureClash 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.



enter image description here



I have this menu, with the News category. This category loads a CMS Block:



enter image description here



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:



enter image description here



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.










share|improve this question





















  • 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
















up vote
2
down vote

favorite












I would like to be able to redirect to a url when the user clicks the category.



enter image description here



I have this menu, with the News category. This category loads a CMS Block:



enter image description here



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:



enter image description here



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.










share|improve this question





















  • 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












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.



enter image description here



I have this menu, with the News category. This category loads a CMS Block:



enter image description here



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:



enter image description here



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.










share|improve this question













I would like to be able to redirect to a url when the user clicks the category.



enter image description here



I have this menu, with the News category. This category loads a CMS Block:



enter image description here



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:



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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
















  • 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










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:



  1. Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".

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






share|improve this answer



























    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',
    ]);









    share|improve this answer






















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      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






























      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:



      1. Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".

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






      share|improve this answer
























        up vote
        2
        down vote



        accepted










        You don't have to build an extension for this.
        You can do the following:



        1. Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".

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






        share|improve this answer






















          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:



          1. Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".

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






          share|improve this answer












          You don't have to build an extension for this.
          You can do the following:



          1. Create new category in Products -> Categories and set a meta title inside Search Engine Optimization, for example: "News".

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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 22 mins ago









          Amir

          1114




          1114






















              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',
              ]);









              share|improve this answer


























                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',
                ]);









                share|improve this answer
























                  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',
                  ]);









                  share|improve this answer














                  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',
                  ]);










                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 1 hour ago

























                  answered 2 hours ago









                  Amit Bera♦

                  54.4k1366158




                  54.4k1366158



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      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













































































                      Comments

                      Popular posts from this blog

                      What does second last employer means? [closed]

                      List of Gilmore Girls characters

                      One-line joke