Advertisement

Cannot Define Variable

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
gtsound
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon May 09, 2011 7:08 am

Cannot Define Variable

Post by gtsound » Tue May 10, 2011 8:17 am

I have an error notice on my article pages: Notice: Undefined variable: ishomepage in /home/content...

However, it does not show up on the homepage or the contact page. The specific line is 57 which i have made bold below.

The goal is to have a homepage, with a header pic as well as modules below and have a different setup for every other page. It works, with the exception of the notice on article pages. Thanks in advance for help!

Code: Select all

//--><!]]></script></head>
<?php if (JRequest::getVar('option')=='com_content' && (JRequest::getVar('view')=='frontpage')) { $ishomepage=1; }?>
<?php if ($this->countModules('sidebar')) {$contentwide=0;} ?>

<body>	
<div id="container">
	<div id="top">
		<div id="logo">
              		<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/logo.png" border="0" alt="logo"></a></div>
		<div id="topright">
			<div id="topmenu">
				<jdoc:include type="modules" name="topmenu" />
			</ul>
			</div>
			<div id="search"><jdoc:include type="modules" name="search" /></div>
			<div class="cleaner"></div>
		</div>
		<div class="cleaner"></div>
	</div>
	<div id="nav">
		<jdoc:include type="modules" name="mainmenu" />
	</div>
	<div id="slogan"><jdoc:include type="modules" name="slogan" /></div>
	<div class="cleaner"></div>

[b][u]<?php if ($ishomepage == '1')  { ?>[/u][/b]
	
       <div id="header">
		<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/header.jpg"   border="0" alt="logo"><jdoc:include type="modules" name="orca_header" /></div>
	
	<div id="bottommodules">
		<div class="bottommodule"><jdoc:include type="modules" name="bottom1" style="xhtml"/></div>
		<div class="bottommodule two"><jdoc:include type="modules" name="bottom2" style="xhtml"/></div>
		<div class="bottommodule last"><jdoc:include type="modules" name="bottom3" style="xhtml"/></div>
		<div class="cleaner"></div>
	</div>

<?php } else { ?>
	
	<div id="main">
		
		<?php if ($contentwide=1) {?>
		<div id="sidebar">
			<jdoc:include type="modules" name="sidebar" style="xhtml" />
		</div>
		<?php } ?>
		<div id="content"<?php if ($contentwide==0) {echo ' class="wide"';}?>>
			<div id="breadcrumb"> <jdoc:include type="modules" name="breadcrumb" /></div>
			<div id="contenttop"><jdoc:include type="modules" name="contenttop" /></div>
			<jdoc:include type="message" />
			<jdoc:include type="component" /></div>
		<div class="cleaner"></div>
		</div>
<?php } ?>

Advertisement
User avatar
GandalfGrey
Joomla! Guru
Joomla! Guru
Posts: 723
Joined: Tue Mar 25, 2008 8:18 pm
Location: Sweden / Haninge

Re: Cannot Define Variable

Post by GandalfGrey » Tue May 10, 2011 9:30 am

The problem is that if this IF statement returns false

Code: Select all

<?php if (JRequest::getVar('option')=='com_content' && (JRequest::getVar('view')=='frontpage')) { $ishomepage=1; }?>

the $ishomepage variable is never declared, so try to change it to this

Code: Select all

<?php
 $ishomepage=0;
if (JRequest::getVar('option')=='com_content' && (JRequest::getVar('view')=='frontpage')) { $ishomepage=1; }?>
“We can't solve problems by using the same kind of thinking we used when we created them."

User avatar
jakow86
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 112
Joined: Sun Feb 10, 2008 6:27 pm
Location: Łódź, Poland
Contact:

Re: Cannot Define Variable

Post by jakow86 » Tue May 10, 2011 10:42 am

If your condition is met (the component is com_content and the view is frontpage) you declare the variable with the value 1, if the condition is not met, you are not declaring it at all.

Solution:

Code: Select all

<?php $ishomepage =  (JRequest::getVar('option')=='com_content' && (JRequest::getVar('view')=='frontpage')); ?>
This way the variable will always be declared, but the value will depend on the condition.

I hope this is helps.
Get professional Joomla! help now - http://joomladesk.eu/ - commercial Joomla! support on monthly subscription basis

gtsound
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon May 09, 2011 7:08 am

Re: Cannot Define Variable

Post by gtsound » Wed May 11, 2011 6:22 pm

IT WORKED!!!!!!

Thanks guys, I had been banging my head against a wall trying to fix it.

Advertisement

Locked

Return to “Templates for Joomla! 1.5”