Solved

Trying to control page layout tags with php if statements

Posted on 2013-06-01
1
616 Views
Last Modified: 2013-06-03
Hello,

I am working on a joomla website (http://testingtesting1.info/jutwynne/)

The homepage is assigned to "Featured Articles", but I will not have any "featured articles", its only assigned to this because the menu has to be assigned to something.

Now when you are on the homepage I have this if statment

<?php if ($this->countModules('latest-news')) : ?>

Open in new window


The latest-news module is only assigned to the homepage, therefore if you are on the homepage only the specific homepage layout tags and the other modules assigned to the homepage will load.

Code here:
<div id="home">
						<div id="lft-column" class="float-left">
							<jdoc:include type="modules" name="latest-news" style="none" />
						</div>
						<!-- END LEFT -->	
						<div id="rt-column" class="float-right">
							<div id="featured-video">
								<div class="title">
									<jdoc:include type="modules" name="featured-video-title" style="none" />
								</div>
									<jdoc:include type="modules" name="featured-video" style="none" />
							</div>
							<!-- END RECENT -->
							<div id="social-feed">
								<div class="title">
									<jdoc:include type="modules" name="social-feed-title" style="none" />
								</div>
									<jdoc:include type="modules" name="social-feed" style"none" />
							</div>
							<!-- END SOCIAL-FEED -->
						</div>
						<!-- END RIGHT -->				
					</div>
					<!-- END HOME -->

Open in new window


Now this works fine. If you go anywhere else on the website the code tags specific to the homepage vanish and only the code for the article appears.

Now for the article specific layout tags I have this if statement:

<?php /*see if we are on the homepage, if not load article tags and modules*/ 
				$menu = &JSite::getMenu();
				 if (JRequest::getInt('Itemid') != $menu->getDefault()) : ?>

Open in new window


The issue is that the above code does not seem to be working on the actual homepage. The article specific layout tags (see below) will load anyway regardless if you are on the homepage - but it should NOT load at all when on the homepage. Additionally, the article tags are empty (no content is contained within them).

If you use firebug or whatever developer you will see right after the <div id="home"> declaration this:

<div id="article" class="float-left">
<div id="additional-links" class="float-right"> </div>

Open in new window


Obviously I am missing some logic flow, but for the life of me I seem unable to locate this missing logic.

Also, related or unrelated to the above issue - when on the homepage and you click on the first two READ MORE links within the text bubbles (Category 3, Category 2) the article loads within the homepage inside the article tags (with both homepage layout and article layout both loaded), but if you click the READ MORE link for Category 1 you are directed (as you are suppose to for the first 2 read more links) to the actual article page. Any ideas why this is happening?

Below is all of my code.

Any help would be great.

Thanks,

Morgan

<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  Templates.jutwynne
 *
 * @copyright   Copyright (C) 2007 - 2013 TotalEEYou.com, Inc. All rights reserved.
 */

defined('_JEXEC') or die;

// Getting params from template
$params = JFactory::getApplication()->getTemplate(true)->params;

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');

if($task == "edit" || $layout == "form" )
{
	$fullWidth = 1;
}
else
{
	$fullWidth = 0;
}

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');

// Add Stylesheets
$doc->addStyleSheet('templates/'.$this->template.'/css/template.css');

// Load optional RTL Bootstrap CSS
JHtml::_('bootstrap.loadCss', false, $this->direction);

// Add current user information
$user = JFactory::getUser();

// Logo file or site title param
if ($this->params->get('logoFile'))
{
	$logo = '<img src="'. JURI::root() . $this->params->get('logoFile') .'" alt="'. $sitename .'" />';
}
elseif ($this->params->get('sitetitle'))
{
	$logo = '<span class="site-title" title="'. $sitename .'">'. htmlspecialchars($this->params->get('sitetitle')) .'</span>';
}
else
{
	$logo = '<span class="site-title" title="'. $sitename .'">'. $sitename .'</span>';
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<jdoc:include type="head" />
	<?php
	// Use of Google Font
	if ($this->params->get('googleFont'))
	{
	?>
		<link href='http://fonts.googleapis.com/css?family=<?php echo $this->params->get('googleFontName');?>' rel='stylesheet' type='text/css' />
		<style type="text/css">
			h1,h2,h3,h4,h5,h6,.site-title{
				font-family: '<?php echo str_replace('+', ' ', $this->params->get('googleFontName'));?>', sans-serif;
			}
		</style>
	<?php
	}
	?>
	<!--[if lt IE 9]>
		<script src="<?php echo $this->baseurl ?>/media/jui/js/html5.js"></script>
	<![endif]-->
	<script type="text/javascript" src="http://testingtesting1.info/jutwynne/templates/jutwynne/js/background.js" ></script>
</head>

<body>
	<div id="bg" >
		<!-- Body -->
		<div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : '');?>">
			<!-- Header -->
			<div id="header">
				<div class="header-inner clearfix">
					<a class="brand pull-left" href="<?php echo $this->baseurl; ?>">
						<?php echo $logo;?> <?php if ($this->params->get('sitedescription')) { echo '<div class="site-description">'. htmlspecialchars($this->params->get('sitedescription')) .'</div>'; } ?></a>
					<div class="header-search pull-right">
						<jdoc:include type="modules" name="position-0" style="none" />
					</div>
					<?php if ($this->countModules('nav-menu')) : ?>
						<div id="top-nav">
							<jdoc:include type="modules" name="nav-menu" style="none" />
						</div>
					<?php endif; ?>
				</div>
			</div>
			<!-- END HEADER -->
			<!-- BEGIN Content -->
			<div class="content" >
				<?php if ($this->countModules('latest-news')) : ?>
					<div id="home">
						<div id="lft-column" class="float-left">
							<jdoc:include type="modules" name="latest-news" style="none" />
						</div>
						<!-- END LEFT -->	
						<div id="rt-column" class="float-right">
							<div id="featured-video">
								<div class="title">
									<jdoc:include type="modules" name="featured-video-title" style="none" />
								</div>
									<jdoc:include type="modules" name="featured-video" style="none" />
							</div>
							<!-- END RECENT -->
							<div id="social-feed">
								<div class="title">
									<jdoc:include type="modules" name="social-feed-title" style="none" />
								</div>
									<jdoc:include type="modules" name="social-feed" style"none" />
							</div>
							<!-- END SOCIAL-FEED -->
						</div>
						<!-- END RIGHT -->				
					</div>
					<!-- END HOME -->
				<?php endif; ?>
				
				<?php /*see if we are on the homepage, if not load article tags and modules*/ 
				$menu = &JSite::getMenu();
				 if (JRequest::getInt('Itemid') != $menu->getDefault()) : ?>
					<?php /*float article left if position rt-column is selected*/
					if ($this->countModules('rt-column')) : ?>
						<!-- BEGIN ARTICLE -->
						<div id="article" class="float-left">
							<!-- Begin Content -->
								<div id="article-top"></div>
								<jdoc:include type="component" />
								<div id="article-btm"></div>
							<!-- End Content -->
						</div>
						<div id="additional-links" class="float-right">
							<jdoc:include type="modules" name="rt-column" style="none" />
						</div>
						<!-- END ARTICLE -->
					<?php endif; ?>
					<?php /*float article right if position lft-column is selected*/
					if ($this->countModules('lft-column')) : ?>
						<!-- BEGIN ARTICLE -->
						<div id="article" class="float-right">
							<!-- Begin Content -->
							<div id="article-top"></div>
							<jdoc:include type="component" />
							<div id="article-btm"></div>
							<!-- End Content -->
						</div>
						<div id="additional-links" class="float-left">
							<jdoc:include type="modules" name="lft-column" style="none" />
						</div>
						<!-- END ARTICLE -->
					<?php endif; ?>
				<?php endif; ?>
				</div>
			</div>
			<!-- END CONTENT -->
		<!-- END CONTAINER -->
		<!-- Footer -->
		<div id="footer">
			<div class="container">
				<jdoc:include type="modules" name="footer" style="none" />
				<p>&copy; <?php echo $sitename; ?> <?php echo date('Y');?></p>
			</div>
			<!-- END CONTAINER -->
		</div>
		<!-- END FOOTER -->
		<jdoc:include type="modules" name="debug" style="none" />
		<jdoc:include type="message" />
	</div>
</body>
</html>

Open in new window

0
Comment
Question by:Morgan
1 Comment
 
LVL 1

Accepted Solution

by:
Morgan earned 0 total points
ID: 39217118
I have found an answer. I had to change the if statement to:

<?php /*see if we are on the homepage, if not load article tags and modules*/ 
$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() != $menu->getDefault()) : ?>

Open in new window

0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

829 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