?
Solved

identify joomla frontpage

Posted on 2008-10-17
4
Medium Priority
?
1,542 Views
Last Modified: 2013-12-13
I want a certain piece of code to execute if the frontpage is loaded and another piece of code to be executed on any other page. I have used the attached code but it doesnt work. all pages cause the 'else' part of the conditional to be executed.
<?php if(($_REQUEST['view'] == 'frontpage') || ($_REQUEST['option'] == 'com_frontpage'))
 	$page="home"; ?>
 
 
 <?php if($page=="home") { ?>
			<img src="<?php echo $this->baseurl;?>/templates/<?php echo $this->template;?>/images/FURNITURE-COMPANY_11.jpg" width="697" height="441" alt=""> <?php } 
			  else { echo "page is " . $page; ?> <br /><br /><jdoc:include type="component" /><?php }?>

Open in new window

0
Comment
Question by:nmichele
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 13

Assisted Solution

by:AielloJ
AielloJ earned 2000 total points
ID: 22739562
nmichele:

Your if statement is controlled by the 'view' and 'option' elements of the $_REQUEST array.  Try printing them out to see of they are the values you're expecting.  You can temporarily use echo statements to print the values or use:

print_r($_REQUEST);

to get a debug printout of everything in the $_REQUEST array.
0
 

Author Comment

by:nmichele
ID: 22739670
Hi AielloJ:
Thanks for the tip. the request array displays the option variable as having the value com_virtuemart, which is the component on the page. However, this component is supposed to display on every page. I would like to identify the home page so that the component details are not displayed in the main content pane of the home page, but are displayed on every other page. which variable of the array would display this? or what code would i need to input?
0
 
LVL 13

Accepted Solution

by:
AielloJ earned 2000 total points
ID: 22739886
I'm assuming the 'view' element didn't have the value 'frontpage' either, since your code would have worked as expected.  The following line of script will return the current page name.

  substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);

You can add a line that tests if it's the home page, and take action based on that.  Assuming your home page is named index.php you could use the following code:

  if (substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1) == 'index.php')
  {
    // We are on the home page.
  }
  else
  {
    // We are NOT on the home page.
  }
0
 

Author Comment

by:nmichele
ID: 22753331
Thanks AielloJ :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question