Page 1 of 1

Adding a div around intro articles (like leading article)

Posted: Thu Dec 10, 2009 4:18 am
by mycompleteness
Hi there,

I'm editing the core default.php front page file, in hope of putting a div around each introduction article (I want to style the leading and intro articles differently). The leading article has a div surrounding by default, but I'm still getting my head around PHP and would like to know where a div should be put to work for the subsequent intro articles.

In default.php, I'm thinking it needs to go in here somewhere (lines 33-70):

Code: Select all

		<?php
			$divider = '';
			if ($this->params->def('multi_column_order',1)) : // order across as before
			for ($z = 0; $z < $this->params->def('num_columns', 2); $z ++) :
				if ($z > 0) : $divider = " column_separator"; endif; ?>
				<?php
				    $rows = (int) ($this->params->get('num_intro_articles', 4) / $this->params->get('num_columns'));
				    $cols = ($this->params->get('num_intro_articles', 4) % $this->params->get('num_columns'));
				?>
				<td valign="top" width="<?php echo intval(100 / $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
				<?php
				$loop = (($z < $cols)?1:0) + $rows;

				for ($y = 0; $y < $loop; $y ++) :
					$target = $i + ($y * $this->params->get('num_columns')) + $z;
					if ($target < $this->total && $target < ($numIntroArticles)) :
						$this->item =& $this->getItem($target, $this->params);
						echo $this->loadTemplate('item');
					endif;
				endfor;
						?></td>
						<?php endfor; 
						$i = $i + $this->params->get('num_intro_articles') ; 
			else : // otherwise, order down columns, like old category blog
				for ($z = 0; $z < $this->params->get('num_columns'); $z ++) :
					if ($z > 0) : $divider = " column_separator"; endif; ?>
					<td valign="top" width="<?php echo intval(100 / $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
					<?php for ($y = 0; $y < ($this->params->get('num_intro_articles') / $this->params->get('num_columns')); $y ++) :
					if ($i < $this->total && $i < ($numIntroArticles)) :
						$this->item =& $this->getItem($i, $this->params);
						echo $this->loadTemplate('item');
						$i ++;
					endif;
				endfor; ?>
				</td>
		<?php endfor; 
		endif;?>
Could someone point out where I need to put the div for this to work?

Cheers.

Re: Adding a div around intro articles (like leading article)

Posted: Thu Dec 10, 2009 4:49 am
by mycompleteness
To add, I've also tried the following edit (closing PHP lines so I could put the divs in), but this causes the articles to disappear completely.

Thanks.

Code: Select all

			<td valign="top" width="<?php echo intval(100 / $this->params->get('num_columns')) ?>%" class="article_column<?php echo $divider ?>">
                
				<?php
				$loop = (($z < $cols)?1:0) + $rows;

				for ($y = 0; $y < $loop; $y ++) :
					$target = $i + ($y * $this->params->get('num_columns')) + $z;
					if ($target < $this->total && $target < ($numIntroArticles)) : break; ?>
					<div class="intro">
                    <?php
						$this->item =& $this->getItem($target, $this->params);
						echo $this->loadTemplate('item');
					?>
						</div>
                    <?php endif;
						endfor;
						?></td>

Re: Adding a div around intro articles (like leading article)

Posted: Thu Dec 10, 2009 4:54 am
by mycompleteness
Of course, I've figured it out now:

Code: Select all

if ($target < $this->total && $target < ($numIntroArticles)) : break; ?>
This line just needed "break;" removed and everything works as planned. All intro articles are now in separate boxes with a different background and text size than the leading article :D