Check page url is category page or cms
I have an page url of magento site.
my question is : how can i check the page url is category page or cms page or other page?
for example:
page URL is : http://example.com/craft.html(category page) or http://example.com/terms-policy(cms page)
i want to check page url is category page or cms page.
Thanks.
magento-1.9 category url cms page
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have an page url of magento site.
my question is : how can i check the page url is category page or cms page or other page?
for example:
page URL is : http://example.com/craft.html(category page) or http://example.com/terms-policy(cms page)
i want to check page url is category page or cms page.
Thanks.
magento-1.9 category url cms page
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
1
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
You need to check in Tablecore_url_rewrite
andcms_page
for this
– Minesh Patel
Dec 16 '17 at 12:58
add a comment |
I have an page url of magento site.
my question is : how can i check the page url is category page or cms page or other page?
for example:
page URL is : http://example.com/craft.html(category page) or http://example.com/terms-policy(cms page)
i want to check page url is category page or cms page.
Thanks.
magento-1.9 category url cms page
I have an page url of magento site.
my question is : how can i check the page url is category page or cms page or other page?
for example:
page URL is : http://example.com/craft.html(category page) or http://example.com/terms-policy(cms page)
i want to check page url is category page or cms page.
Thanks.
magento-1.9 category url cms page
magento-1.9 category url cms page
edited Dec 16 '17 at 12:15
pooja
asked Dec 16 '17 at 11:55
poojapooja
93111
93111
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ yesterday
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
1
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
You need to check in Tablecore_url_rewrite
andcms_page
for this
– Minesh Patel
Dec 16 '17 at 12:58
add a comment |
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
1
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
You need to check in Tablecore_url_rewrite
andcms_page
for this
– Minesh Patel
Dec 16 '17 at 12:58
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
1
1
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
You need to check in Table
core_url_rewrite
and cms_page
for this– Minesh Patel
Dec 16 '17 at 12:58
You need to check in Table
core_url_rewrite
and cms_page
for this– Minesh Patel
Dec 16 '17 at 12:58
add a comment |
1 Answer
1
active
oldest
votes
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
if (Mage::registry('current_category'))
{
// category page
}
To check if it is a cms page:
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
// CMS page
}
To check if it is a product page:
if(Mage::registry('current_product'))
{
// Product detail page
}
Edited
From your comment, below code will let you know the last page url is either cms page, or category or product.
$lastUrl = Mage::getSingleton('core/session')->getLastUrl();
if (preg_match("#cms/index/index#", $lastUrl)) {
return "Last page was:<br>Home page<br/>url: ".$lastUrl;
}
elseif(preg_match("#catalog/category/view#", $lastUrl)) {
return "Last page was:<br>Category page<br/>url: ".$lastUrl;
}
elseif (preg_match("#catalog/product/view#", $lastUrl)) {
return "Last page was:<br>Product detail page<br/>url: ".$lastUrl;
}
else
{
return "Last page was:<br>Unknown page<br/>url: ".$lastUrl;
}
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
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');
});
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%2f206094%2fcheck-page-url-is-category-page-or-cms%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
if (Mage::registry('current_category'))
{
// category page
}
To check if it is a cms page:
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
// CMS page
}
To check if it is a product page:
if(Mage::registry('current_product'))
{
// Product detail page
}
Edited
From your comment, below code will let you know the last page url is either cms page, or category or product.
$lastUrl = Mage::getSingleton('core/session')->getLastUrl();
if (preg_match("#cms/index/index#", $lastUrl)) {
return "Last page was:<br>Home page<br/>url: ".$lastUrl;
}
elseif(preg_match("#catalog/category/view#", $lastUrl)) {
return "Last page was:<br>Category page<br/>url: ".$lastUrl;
}
elseif (preg_match("#catalog/product/view#", $lastUrl)) {
return "Last page was:<br>Product detail page<br/>url: ".$lastUrl;
}
else
{
return "Last page was:<br>Unknown page<br/>url: ".$lastUrl;
}
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
add a comment |
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
if (Mage::registry('current_category'))
{
// category page
}
To check if it is a cms page:
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
// CMS page
}
To check if it is a product page:
if(Mage::registry('current_product'))
{
// Product detail page
}
Edited
From your comment, below code will let you know the last page url is either cms page, or category or product.
$lastUrl = Mage::getSingleton('core/session')->getLastUrl();
if (preg_match("#cms/index/index#", $lastUrl)) {
return "Last page was:<br>Home page<br/>url: ".$lastUrl;
}
elseif(preg_match("#catalog/category/view#", $lastUrl)) {
return "Last page was:<br>Category page<br/>url: ".$lastUrl;
}
elseif (preg_match("#catalog/product/view#", $lastUrl)) {
return "Last page was:<br>Product detail page<br/>url: ".$lastUrl;
}
else
{
return "Last page was:<br>Unknown page<br/>url: ".$lastUrl;
}
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
add a comment |
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
if (Mage::registry('current_category'))
{
// category page
}
To check if it is a cms page:
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
// CMS page
}
To check if it is a product page:
if(Mage::registry('current_product'))
{
// Product detail page
}
Edited
From your comment, below code will let you know the last page url is either cms page, or category or product.
$lastUrl = Mage::getSingleton('core/session')->getLastUrl();
if (preg_match("#cms/index/index#", $lastUrl)) {
return "Last page was:<br>Home page<br/>url: ".$lastUrl;
}
elseif(preg_match("#catalog/category/view#", $lastUrl)) {
return "Last page was:<br>Category page<br/>url: ".$lastUrl;
}
elseif (preg_match("#catalog/product/view#", $lastUrl)) {
return "Last page was:<br>Product detail page<br/>url: ".$lastUrl;
}
else
{
return "Last page was:<br>Unknown page<br/>url: ".$lastUrl;
}
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!
I think the answer given by Minesh in comments are partially correct. If you are trying to check it in your template file you can use below codes to check whether you are in category page, cms page or product page.
To check if you are in category page:
if (Mage::registry('current_category'))
{
// category page
}
To check if it is a cms page:
if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms')
{
// CMS page
}
To check if it is a product page:
if(Mage::registry('current_product'))
{
// Product detail page
}
Edited
From your comment, below code will let you know the last page url is either cms page, or category or product.
$lastUrl = Mage::getSingleton('core/session')->getLastUrl();
if (preg_match("#cms/index/index#", $lastUrl)) {
return "Last page was:<br>Home page<br/>url: ".$lastUrl;
}
elseif(preg_match("#catalog/category/view#", $lastUrl)) {
return "Last page was:<br>Category page<br/>url: ".$lastUrl;
}
elseif (preg_match("#catalog/product/view#", $lastUrl)) {
return "Last page was:<br>Product detail page<br/>url: ".$lastUrl;
}
else
{
return "Last page was:<br>Unknown page<br/>url: ".$lastUrl;
}
I hope this will help. If it works for you pleae don't forget to accept and vote the answer. This will help others too.
Happy Coding!!
edited Dec 18 '17 at 9:30
answered Dec 16 '17 at 15:54
aton1004aton1004
633823
633823
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
add a comment |
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
1
1
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
your answer is correct @aton1004 but i need to get the page type on another page. for example: if i am on category page and its previous page is home page then i need to show home page type (cms) show on category page. inshort, i need to know the previous page type. is it cms or category.
– pooja
Dec 18 '17 at 7:00
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
@pooja from your question it was not clear of your requirement. Please check the code from edited section to find your answer. if it helps don't forget to accept and vote up the answer. Cheers!!
– aton1004
Dec 18 '17 at 9:30
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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');
});
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%2f206094%2fcheck-page-url-is-category-page-or-cms%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');
});
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');
});
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');
});
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
$this->getRequest()->getControllerName() == 'cms' is CMS page
– Minesh Patel
Dec 16 '17 at 12:05
blog.chapagain.com.np/…
– Minesh Patel
Dec 16 '17 at 12:06
1
hi @MineshPatel no i don't want this. your code match current page controller name with "cms". i edit my question with an example please see.
– pooja
Dec 16 '17 at 12:12
You need to check in Table
core_url_rewrite
andcms_page
for this– Minesh Patel
Dec 16 '17 at 12:58