{"id":773,"date":"2012-03-27T17:50:25","date_gmt":"2012-03-27T15:50:25","guid":{"rendered":"http:\/\/www.kavdesign.net\/blog\/?p=773"},"modified":"2012-03-27T17:54:38","modified_gmt":"2012-03-27T15:54:38","slug":"how-to-get-front-page-in-joomla-2-5","status":"publish","type":"post","link":"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-get-front-page-in-joomla-2-5\/","title":{"rendered":"How to get front page in Joomla 2.5"},"content":{"rendered":"<h2 id=\"firstHeading\">How to determine if the user is viewing the front page<\/h2>\n<h2><a title=\"Joomla 1.0\" href=\"http:\/\/docs.joomla.org\/File:Compat_icon_1_0.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/docs.joomla.org\/images\/4\/43\/Compat_icon_1_0.png\" alt=\"Joomla 1.0\" width=\"39\" height=\"16\" \/><\/a> Joomla 1.0<\/h2>\n<p>In Joomla! 1.0.x it was possible to determine if the user was viewing the front page by using code like this:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;?php\r\nif ($option == 'com_frontpage' || $option == '') {\r\n\techo 'This is the front page';\r\n}\r\n?&gt;<\/pre>\n<\/div>\n<\/div>\n<h2><a title=\"Joomla 1.5\" href=\"http:\/\/docs.joomla.org\/File:Compat_icon_1_5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/docs.joomla.org\/images\/c\/c8\/Compat_icon_1_5.png\" alt=\"Joomla 1.5\" width=\"39\" height=\"16\" \/><\/a> Joomla 1.5<\/h2>\n<p>But in Joomla! 1.5.x the com_frontpage component is no longer present. This is how to achieve the same result in Joomla! 1.5.x<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;?php\r\n$menu = &amp; JSite::getMenu();\r\nif ($menu-&gt;getActive() == $menu-&gt;getDefault()) {\r\n\techo 'This is the front page';\r\n}\r\n?&gt;<\/pre>\n<\/div>\n<\/div>\n<p>This works by checking to see if the current active menu item is the default one.<\/p>\n<h2><a title=\"Joomla 1.6\" href=\"http:\/\/docs.joomla.org\/File:Compat_icon_1_6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/docs.joomla.org\/images\/d\/da\/Compat_icon_1_6.png\" alt=\"Joomla 1.6\" width=\"39\" height=\"16\" \/><\/a> <a title=\"Joomla 1.7\" href=\"http:\/\/docs.joomla.org\/File:Compat_icon_1_7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/docs.joomla.org\/images\/8\/87\/Compat_icon_1_7.png\" alt=\"Joomla 1.7\" width=\"39\" height=\"16\" \/><\/a> <a title=\"Joomla 2.5\" href=\"http:\/\/docs.joomla.org\/File:Compat_icon_2_5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/docs.joomla.org\/images\/5\/53\/Compat_icon_2_5.png\" alt=\"Joomla 2.5\" width=\"39\" height=\"16\" \/><\/a> Joomla 1.6, 1.7 and 2.5<\/h2>\n<p>This is one of the ways:<\/p>\n<pre>&lt;?php if (JRequest::getInt('Itemid') == your_id) : ?&gt;\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;!-- special javascript --&gt;\r\n&lt;?php endif; ?&gt;<\/pre>\n<p>There are some differences in 1.6\/1.7\/2.5 to avoid Strict Standards errors. Use the following code for a site where all content is in the same language:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;?php\r\n$app = JFactory::getApplication();\r\n$menu = $app-&gt;getMenu();\r\nif ($menu-&gt;getActive() == $menu-&gt;getDefault()) {\r\n\techo 'This is the front page';\r\n}\r\n?&gt;<\/pre>\n<\/div>\n<\/div>\n<p>For multi-lingual sites the front page is dependent on the currently selected language, so you will need to use code like this:<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;?php\r\n$app = JFactory::getApplication();\r\n$menu = $app-&gt;getMenu();\r\nif ($menu-&gt;getActive() == $menu-&gt;getDefault( 'en-GB' )) {\r\n\techo 'This is the front page';\r\n}\r\nelseif ($menu-&gt;getActive() == $menu-&gt;getDefault( 'fr-FR' )) {\r\n\techo 'Accueil';\r\n}\r\n?&gt;<\/pre>\n<\/div>\n<\/div>\n<p>For multi-lingual sites, it could also be necessary to display a specific code\/html for <strong>all<\/strong> Default Home pages.<\/p>\n<div dir=\"ltr\">\n<div>\n<pre>&lt;?php $app = JFactory::getApplication(); ?&gt;\r\n&lt;?php $menu = $app-&gt;getMenu(); ?&gt;\r\n&lt;?php $lang = JFactory::getLanguage(); ?&gt;\r\n&lt;?php if ($menu-&gt;getActive() == $menu-&gt;getDefault($lang-&gt;getTag())) : ?&gt;\r\netc.<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>For more info:<\/strong> <a href=\"http:\/\/docs.joomla.org\/How_to_determine_if_the_user_is_viewing_the_front_page\" target=\"_blank\">http:\/\/docs.joomla.org\/How_to_determine_if_the_user_is_viewing_the_front_page<\/a><\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>How to determine if the user is viewing the front page Joomla 1.0 In Joomla! 1.0.x it was possible to determine if the user was&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/www.kavdesign.net\/blog\/coding\/how-to-get-front-page-in-joomla-2-5\/\">Continue reading<span class=\"screen-reader-text\">How to get front page in Joomla 2.5<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[9,29],"tags":[240,417],"class_list":["post-773","post","type-post","status-publish","format-standard","hentry","category-coding","category-joomla","tag-front-page","tag-joomla","entry"],"_links":{"self":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/comments?post=773"}],"version-history":[{"count":6,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/773\/revisions"}],"predecessor-version":[{"id":779,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/posts\/773\/revisions\/779"}],"wp:attachment":[{"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/media?parent=773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/categories?post=773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kavdesign.net\/blog\/wp-json\/wp\/v2\/tags?post=773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}