Solved

identify joomla frontpage

Posted on 2008-10-17
4
1,540 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 500 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 500 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This article discusses how to implement server side field validation and display customized error messages to the client.
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 look for a specific file type in a local or remote server directory using PHP.

734 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