Max URL Levels in Controller Magento 2
I have custom controller outputting JSON format which works well for the below URL level;
** Works
base url/module/folder/action
//equates to VendorModuleControllerFolderIndex.php
However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;
**Hit with 404
base url/module/folder/anotherfolder/action
//equates to VendorModuleControllerFolderAnotherfolderIndex.php
/* or even deeper */
**Hit with 404 - not tested
base url/module/folder/anotherfolder/deeperfolder/action
//equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...
For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)
magento2 url controllers
add a comment |
I have custom controller outputting JSON format which works well for the below URL level;
** Works
base url/module/folder/action
//equates to VendorModuleControllerFolderIndex.php
However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;
**Hit with 404
base url/module/folder/anotherfolder/action
//equates to VendorModuleControllerFolderAnotherfolderIndex.php
/* or even deeper */
**Hit with 404 - not tested
base url/module/folder/anotherfolder/deeperfolder/action
//equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...
For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)
magento2 url controllers
add a comment |
I have custom controller outputting JSON format which works well for the below URL level;
** Works
base url/module/folder/action
//equates to VendorModuleControllerFolderIndex.php
However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;
**Hit with 404
base url/module/folder/anotherfolder/action
//equates to VendorModuleControllerFolderAnotherfolderIndex.php
/* or even deeper */
**Hit with 404 - not tested
base url/module/folder/anotherfolder/deeperfolder/action
//equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...
For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)
magento2 url controllers
I have custom controller outputting JSON format which works well for the below URL level;
** Works
base url/module/folder/action
//equates to VendorModuleControllerFolderIndex.php
However I would like some somewhat deeper nested URL endpoints as per below but I get 404 on controllers deeper that one folder;
**Hit with 404
base url/module/folder/anotherfolder/action
//equates to VendorModuleControllerFolderAnotherfolderIndex.php
/* or even deeper */
**Hit with 404 - not tested
base url/module/folder/anotherfolder/deeperfolder/action
//equates to VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
I'm guessing Magento2 doesn't allow deep nested URL types or controllers ...
For me, this deeper nesting would be ideal to have a more manageable controller development & access since we have lost the ability to have multiple actions/endpoints in the one controller (Magento 1.*) (advise if not the case)
magento2 url controllers
magento2 url controllers
asked Sep 15 '18 at 2:09
BENN1THBENN1TH
5691516
5691516
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
For this path
VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
URL will be
url/module/folder_anotherfolder_deeperfolder/action
As per as magento URL format is
URL/frontenName/ACtionFolder/Action
Frontendname is defined at routes.xml
ACtionFolder locates at Controller folder which can multiple folders path
but path will connect via (_) Undescore
Action is the php class.
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
add a comment |
In Magento Catalog module has very nice and simple example by adding any product to compare.
Url Action Is :-
http://127.0.0.1/magento/catalog/product_compare/index/
Your Layout is :-
catalog_product_compare_index.xml
Folder structure is :-
/vendor/magento/module-catalog/Controller/Product/Compare/Index.php
It's very simple, magento has many examples.
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f242362%2fmax-url-levels-in-controller-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
For this path
VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
URL will be
url/module/folder_anotherfolder_deeperfolder/action
As per as magento URL format is
URL/frontenName/ACtionFolder/Action
Frontendname is defined at routes.xml
ACtionFolder locates at Controller folder which can multiple folders path
but path will connect via (_) Undescore
Action is the php class.
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
add a comment |
For this path
VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
URL will be
url/module/folder_anotherfolder_deeperfolder/action
As per as magento URL format is
URL/frontenName/ACtionFolder/Action
Frontendname is defined at routes.xml
ACtionFolder locates at Controller folder which can multiple folders path
but path will connect via (_) Undescore
Action is the php class.
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
add a comment |
For this path
VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
URL will be
url/module/folder_anotherfolder_deeperfolder/action
As per as magento URL format is
URL/frontenName/ACtionFolder/Action
Frontendname is defined at routes.xml
ACtionFolder locates at Controller folder which can multiple folders path
but path will connect via (_) Undescore
Action is the php class.
For this path
VendorModuleControllerFolderAnotherfolderDeeperfolderIndex.php
URL will be
url/module/folder_anotherfolder_deeperfolder/action
As per as magento URL format is
URL/frontenName/ACtionFolder/Action
Frontendname is defined at routes.xml
ACtionFolder locates at Controller folder which can multiple folders path
but path will connect via (_) Undescore
Action is the php class.
answered Sep 15 '18 at 4:51
Amit Bera♦Amit Bera
57.4k1474171
57.4k1474171
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
add a comment |
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
Yes indeed this is it. thank you +1
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
ideally I would prefer URL without underscores (underscores changed to forward slashes) but this would need additional rewrites programmatically (and not manually created via admin panel etc)
– BENN1TH
Sep 15 '18 at 6:18
add a comment |
In Magento Catalog module has very nice and simple example by adding any product to compare.
Url Action Is :-
http://127.0.0.1/magento/catalog/product_compare/index/
Your Layout is :-
catalog_product_compare_index.xml
Folder structure is :-
/vendor/magento/module-catalog/Controller/Product/Compare/Index.php
It's very simple, magento has many examples.
add a comment |
In Magento Catalog module has very nice and simple example by adding any product to compare.
Url Action Is :-
http://127.0.0.1/magento/catalog/product_compare/index/
Your Layout is :-
catalog_product_compare_index.xml
Folder structure is :-
/vendor/magento/module-catalog/Controller/Product/Compare/Index.php
It's very simple, magento has many examples.
add a comment |
In Magento Catalog module has very nice and simple example by adding any product to compare.
Url Action Is :-
http://127.0.0.1/magento/catalog/product_compare/index/
Your Layout is :-
catalog_product_compare_index.xml
Folder structure is :-
/vendor/magento/module-catalog/Controller/Product/Compare/Index.php
It's very simple, magento has many examples.
In Magento Catalog module has very nice and simple example by adding any product to compare.
Url Action Is :-
http://127.0.0.1/magento/catalog/product_compare/index/
Your Layout is :-
catalog_product_compare_index.xml
Folder structure is :-
/vendor/magento/module-catalog/Controller/Product/Compare/Index.php
It's very simple, magento has many examples.
edited 4 hours ago
answered 5 hours ago
Manish GoswamiManish Goswami
502314
502314
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f242362%2fmax-url-levels-in-controller-magento-2%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown