PHP IF/ELSE Error

I have this code and am experiencing this error: Parse error: syntax error, unexpected $end in /home/nettrane/public_html/demo-sites/nvi/templates/nvi/index.php on line 161


	<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
    <jdoc:include type="modules" name="bkgrd" style="xhtml" />
    <div id="wrapper">
    <div id="header" class="group">
    <jdoc:include type="modules" name="header" style="xhtml" />
    </div>

<?php if ($this->countModules('pointer')) : ?>
    <div id="point">
    <jdoc:include type="modules" name="pointer" style="xhtml" />
    </div>
    <div id="contentinfo2">
    <div class="paddingsurround group">
    <?php if($this->countModules('left')) : ?>
    <div id="left">
    <jdoc:include type="modules" name="left" style="xhtml" />
    </div>
    <?php endif; ?>
    <div id="content<?php echo $contentwidth; ?>">
    <div class="padding">
    <jdoc:include type="component" />
    </div>
    </div>
    <?php if($this->countModules('right')) : ?>
    <div id="right">
    <jdoc:include type="modules" name="right" style="xhtml" />
    </div>
    <?php endif; ?>
    <?php if($this->countModules('right-int')) : ?>
    <div id="right-int">
    <jdoc:include type="modules" name="right-int" style="xhtml" />
    </div>
    <?php endif; ?>
    </div>
    </div>
    <?php else : ?>


    <?php if ($this->countModules('slidermes')) : ?>
    <div id="slider">
    <jdoc:include type="modules" name="slidermes" style="xhtml" />
    </div>
    <div id="contentinfo">
    <div class="paddingsurround group">
    <?php if($this->countModules('left')) : ?>
    <div id="left">
    <jdoc:include type="modules" name="left" style="xhtml" />
    </div>
    <?php endif; ?>
    <div id="content<?php echo $contentwidth; ?>">
    <div class="padding">
    <jdoc:include type="component" />
    </div>
    </div>
    <?php if($this->countModules('right')) : ?>
    <div id="right">
    <jdoc:include type="modules" name="right" style="xhtml" />
    </div>
    <?php endif; ?>
    <?php if($this->countModules('right-int')) : ?>
    <div id="right-int">
    <jdoc:include type="modules" name="right-int" style="xhtml" />
    </div>
    <?php endif; ?>
    </div>
    </div>
    <?php else : ?>


    <div id="contentinfo2">
    <div class="paddingsurround group">
    <?php if($this->countModules('left')) : ?>
    <div id="left">
    <jdoc:include type="modules" name="left" style="xhtml" />
    </div>
    <?php endif; ?>
    <div id="content<?php echo $contentwidth; ?>">
    <div class="padding">
    <jdoc:include type="component" />
    </div>
    </div>
    <?php if($this->countModules('right')) : ?>
    <div id="right">
    <jdoc:include type="modules" name="right" style="xhtml" />
    </div>
    <?php endif; ?>
    <?php if($this->countModules('right-int')) : ?>
    <div id="right-int">
    <jdoc:include type="modules" name="right-int" style="xhtml" />
    </div>
    <?php endif; ?>
    </div>
    </div>

    <?php endif; ?>
    </div>
    <div id="bottom">
    <jdoc:include type="modules" name="bottommods" style="xhtml" />
    </div>
    <div id="footer">
    <div class="padding group">
    <jdoc:include type="modules" name="footer" style="xhtml" />
    <p id="copyright">New Ventus &copy;<?php echo date("Y") ?></p>
    </div>
    </div>
	</body>
</html>

What I want it to do, if the pointer Module exists (the first ‘if’ statement) then display the content within.

If ‘pointer’ does not, check to see if the ‘slidermes’ module exists. If it does, then display the content within it’s ‘if’ statement.

If it neither module exist, then display the other content (<div id=“confentinfo2”>…)

The “Line 161” that is being referenced is the the <html> tag.

Thank you for the help! I’m sure there’s an easier method to the if/else, and I’m open to suggestions.

Aren’t if and else statements supposed to be enclosed in curly braces?

if
{
something here
}

else
{
something here
}

Not in all cases. I have found that when I added this section:

<?php if ($this->countModules('pointer')) : ?>
    <div id="point">
    <jdoc:include type="modules" name="pointer" style="xhtml" />
    </div>
    <div id="contentinfo2">
    <div class="paddingsurround group">
    <?php if($this->countModules('left')) : ?>
    <div id="left">
    <jdoc:include type="modules" name="left" style="xhtml" />
    </div>
    <?php endif; ?>
    <div id="content<?php echo $contentwidth; ?>">
    <div class="padding">
    <jdoc:include type="component" />
    </div>
    </div>
    <?php if($this->countModules('right')) : ?>
    <div id="right">
    <jdoc:include type="modules" name="right" style="xhtml" />
    </div>
    <?php endif; ?>
    <?php if($this->countModules('right-int')) : ?>
    <div id="right-int">
    <jdoc:include type="modules" name="right-int" style="xhtml" />
    </div>
    <?php endif; ?>
    </div>
    </div>
    <?php else : ?>    

That’s when the error occurred and my other code has worked just fine.

He is using the other acceptable approach by PHP

if <condition> :

else :

endif;

@toad78 ; You need another <?php endif; ?>, so change your last <?php endif; ?> to one of the following:

<?php endif; ?>
<?php endif; ?>

Or

<?php 
    endif;
  endif;
?>

Here is the updated script (with it indented so you can see the heirarchy of the if/else)

<body id="<?php echo $pageclass ? htmlspecialchars($pageclass) : 'default'; ?>">
<jdoc:include type="modules" name="bkgrd" style="xhtml" />
<div id="wrapper">
	<div id="header" class="group">
		<jdoc:include type="modules" name="header" style="xhtml" />
	</div>

	<?php if ($this->countModules('pointer')) : ?>
		<div id="point">
			<jdoc:include type="modules" name="pointer" style="xhtml" />
		</div>
		<div id="contentinfo2">
			<div class="paddingsurround group">
				<?php if($this->countModules('left')) : ?>
					<div id="left">
						<jdoc:include type="modules" name="left" style="xhtml" />
					</div>
				<?php endif; ?>
				<div id="content<?php echo $contentwidth; ?>">
					<div class="padding">
						<jdoc:include type="component" />
					</div>
				</div>
				<?php if($this->countModules('right')) : ?>
					<div id="right">
						<jdoc:include type="modules" name="right" style="xhtml" />
					</div>
				<?php endif; ?>
				<?php if($this->countModules('right-int')) : ?>
					<div id="right-int">
						<jdoc:include type="modules" name="right-int" style="xhtml" />
					</div>
				<?php endif; ?>
			</div>
		</div>
	<?php else : ?>

		<?php if ($this->countModules('slidermes')) : ?>
			<div id="slider">
				<jdoc:include type="modules" name="slidermes" style="xhtml" />
			</div>
			<div id="contentinfo">
				<div class="paddingsurround group">
					<?php if($this->countModules('left')) : ?>
						<div id="left">
							<jdoc:include type="modules" name="left" style="xhtml" />
						</div>
					<?php endif; ?>
					<div id="content<?php echo $contentwidth; ?>">
						<div class="padding">
							<jdoc:include type="component" />
						</div>
					</div>
					<?php if($this->countModules('right')) : ?>
						<div id="right">
							<jdoc:include type="modules" name="right" style="xhtml" />
						</div>
					<?php endif; ?>
					<?php if($this->countModules('right-int')) : ?>
						<div id="right-int">
							<jdoc:include type="modules" name="right-int" style="xhtml" />
						</div>
					<?php endif; ?>
				</div>
			</div>
		<?php else : ?>
		
			<div id="contentinfo2">
				<div class="paddingsurround group">
					<?php if($this->countModules('left')) : ?>
						<div id="left">
							<jdoc:include type="modules" name="left" style="xhtml" />
						</div>
					<?php endif; ?>
					<div id="content<?php echo $contentwidth; ?>">
						<div class="padding">
							<jdoc:include type="component" />
						</div>
					</div>
					<?php if($this->countModules('right')) : ?>
						<div id="right">
							<jdoc:include type="modules" name="right" style="xhtml" />
						</div>
					<?php endif; ?>
					<?php if($this->countModules('right-int')) : ?>
						<div id="right-int">
							<jdoc:include type="modules" name="right-int" style="xhtml" />
						</div>
					<?php endif; ?>
				</div>
			</div>
	
		<?php endif; ?>
	<?php endif; ?>
</div>
<div id="bottom">
	<jdoc:include type="modules" name="bottommods" style="xhtml" />
</div>
<div id="footer">
	<div class="padding group">
		<jdoc:include type="modules" name="footer" style="xhtml" />
		<p id="copyright">New Ventus &copy;<?php echo date("Y") ?></p>
	</div>
</div>
</body>
</html>

Thanks, cpradio. That fixed the error, but I guess my template isn’t working correctly just yet.

It seems that the module ‘pointer’ is showing up in other pages that it isn’t assigned to, which is odd behavior. I only have it assigned to certain pages except for the home page (which uses a ‘slidermes’ module), but it’s showing up in all pages except for home.

Any clues?

Well, I’d have to guess that $this->countModules(‘pointer’) is returning true for all pages except the home page. I’m not familiar with whatever CMS/template system you are using so its a tad bit hard for me to suggest how to debug it. If you feel the PHP portion is wrong, then you are getting true (or a value that equates to true) for $this->countModules(‘pointer’) when you think it should be false. You’d have to determine why that is.

I’m using Joomla CMS (2.5.11) with Advanced Module Manager extensions (which has always worked well).

I wish I knew why the module is returning ‘True’ even though the items I have it assigned to should only be true and not displaying with other items. I wound up creating a ‘display: none’ for that module on specific pages it would display, even though that is not the best method because it doesn’t solve the problem. Hopefully someone will pick up on this and give me a solution.

Thank you for your help, cpradio with the error.