How do I getView() or tell If I am at the home page - SOLVED
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
How do I getView() or tell If I am at the home page - SOLVED
so without checking $_GET(), how do I find out if I am on the home page? I need to have code execute only on home page... any ideas
Thank you
Thank you
Last edited by jbdev on Tue Aug 21, 2007 3:43 pm, edited 1 time in total.
- matthewhayashida
- Joomla! Enthusiast
- Posts: 114
- Joined: Sat Feb 10, 2007 8:26 pm
- Location: Abbotsford, BC
- Contact:
Re: How do I getView() or tell If I am at the home page
Here is a way to tell if you are on the frontpage
I hope this helps.
Code: Select all
<?php if ( $_REQUEST['option'] == "com_frontpage" ) {
echo '<div id="main">';
Text
echo '</div><div id="right">This code displays if page is the frontpage</div>';
}
else {
echo '<div id="main">';
Text
echo '</div>';
}?>
I hope this helps.
-Matt Hayashida
- Chris Davenport
- Joomla! Intern
- Posts: 95
- Joined: Thu Aug 18, 2005 8:57 am
- Location: Shrewsbury, Shropshire, United Kingdom
Re: How do I getView() or tell If I am at the home page
Joomla! Core Team Member | Documentation Working Group Coordinator
"Reality is merely an illusion, although a very persistent one" - Albert Einstein
"We are suspended in language such that we don't know what is up and what is down" - Niels Bohr
"Reality is merely an illusion, although a very persistent one" - Albert Einstein
"We are suspended in language such that we don't know what is up and what is down" - Niels Bohr
- matthewhayashida
- Joomla! Enthusiast
- Posts: 114
- Joined: Sat Feb 10, 2007 8:26 pm
- Location: Abbotsford, BC
- Contact:
Re: How do I getView() or tell If I am at the home page
Cool. I was wondering how to do that in 1.5 Ive been converting a new templates. Thanks!
-Matt Hayashida
-
- Joomla! Apprentice
- Posts: 10
- Joined: Mon Nov 06, 2006 11:03 pm
- Location: Birmingham, UK
Re: How do I getView() or tell If I am at the home page
However, this doesn't really answer the OP's question. The 'frontpage' view does not need to be used on the home page (it can be used anywhere on the site) and the home page does not need to show the 'frontpage' view (it can show a single article if desired).
So, is there a way to check that a user is on the home page, i.e. the page at the top of the main menu (J!1.5) and the one shown when someone goes to http://www.mysite.com ?
So, is there a way to check that a user is on the home page, i.e. the page at the top of the main menu (J!1.5) and the one shown when someone goes to http://www.mysite.com ?
Re: How do I getView() or tell If I am at the home page
Thanks for the help.
This does not work as well because there is not always a request or "view" is not set. Unless I am missing something
here is what I did for now
I created a custom module position and set a empty module for display on the home page in that position. I do not have any calls in the template for the module position but I can use the countmodules() funtion to determine if I am on the home page and fire off what ever code I need.
so if $this->countModules('homefakeid') then else ... etc etc etc
Works for now
This does not work as well because there is not always a request or "view" is not set. Unless I am missing something
Code: Select all
<?php
if (JRequest::getVar('view') === 'frontpage') {
echo 'This is the front page';
}
?>
here is what I did for now
I created a custom module position and set a empty module for display on the home page in that position. I do not have any calls in the template for the module position but I can use the countmodules() funtion to determine if I am on the home page and fire off what ever code I need.
so if $this->countModules('homefakeid') then else ... etc etc etc
Works for now
Last edited by jbdev on Wed Aug 15, 2007 1:59 pm, edited 1 time in total.
Re: How do I getView() or tell If I am at the home page
Hi,
someplace else I recommended to ask the Menu instance.
*IF* your homepage has a link in the mainmenu and *IF* this page is shown == active, you can use this code as well:
Have fun,
CirTap
someplace else I recommended to ask the Menu instance.
*IF* your homepage has a link in the mainmenu and *IF* this page is shown == active, you can use this code as well:
Code: Select all
$jmenu = &JMenu::getInstance();
$menu = $jmenu->getActive();
// return ($menu->query['view'] == 'frontpage');
return ($menu->home);
Have fun,
CirTap
You can have programs written fast, well, and cheap, but you only get to pick 2 ...
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
"I love deadlines. I like the whooshing sound they make as they fly by." Douglas Adams
- louis.landry
- Joomla! Enthusiast
- Posts: 101
- Joined: Wed Aug 17, 2005 11:03 pm
- Location: New Orleans, Louisiana
- Contact:
Re: How do I getView() or tell If I am at the home page
Try something like:
Something like that should get it done.
Louis
Code: Select all
<?php
$menu = &JMenu::getInstance();
if ($menu->getActive() == $menu->getDefault()) {
// The default menu item is the active one .... otherwise said, we are on the front page of the site
}
Something like that should get it done.
Louis
Project Manager :: Developer
http://www.webimagery.net
A hacker does for love what others would not do for money.
http://www.webimagery.net
A hacker does for love what others would not do for money.
Re: How do I getView() or tell If I am at the home page
Thank you that worked perfectly
louis.landry wrote:Try something like:Code: Select all
<?php
$menu = &JMenu::getInstance();
if ($menu->getActive() == $menu->getDefault()) {
// The default menu item is the active one .... otherwise said, we are on the front page of the site
}
Something like that should get it done.
Louis