Skip to content

Instantly share code, notes, and snippets.

@fastnetwebdesign
Created January 8, 2015 18:44
Show Gist options
  • Save fastnetwebdesign/afb58cd8545d3224021e to your computer and use it in GitHub Desktop.
Save fastnetwebdesign/afb58cd8545d3224021e to your computer and use it in GitHub Desktop.
order articles in blog view by fieldsattach id dependant on array
<?php
// Pull in and use FieldsAttach component helper file for getting extra fields id's
JLoader::register('fieldattach', 'components/com_fieldsattach/helpers/fieldattach.php');
?>
<!-- order articles in blog view by fieldsattach id dependant on array -->
<?php foreach ($this->intro_items as $key => &$item)
{
$team = fieldattach::getValue($item->id, 1, false);
if (in_array($team, array('sales', 'both')))
{
$salesTeam[] =& $item;
}
if (in_array($team, array('letting', 'both')))
{
$lettingTeam[] =& $item;
}
} ?>
<?php if (!empty($salesTeam)) : ?>
<div class="content-main">
<h2>Sales</h2>
<p>Lorem ipsum about Sales</p>
<div class="row-fluid row-no-padding clearfix">
<?php foreach ($salesTeam as $key => &$item) : ?>
<div class="tagged-item col-sm-<?php echo round((12 / $this->columns)); ?> col-md-<?php echo round((12 / $this->columns)); ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?><?php if ($counter > 0 and fmod($counter + 1, $this->columns) == 0) : echo ' last'; endif; ?>" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<?php $this->item = &$item; ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>" itemprop="url">
<h3 itemprop="name"><?php echo $this->escape($this->item->title); ?></h3>
<?php $images = json_decode($this->item->images); ?>
<img <?php if ($images->image_intro_caption) : echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_intro_caption) . '"'; endif; ?> src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>" itemprop="thumbnailUrl" />
</a>
</div>
<?php $counter++; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($lettingTeam)) : ?>
<div class="content-main">
<h2>Letting</h2>
<p>Lorem ipsum about Letting</p>
<div class="row-fluid row-no-padding clearfix">
<?php foreach ($lettingTeam as $key => &$item) : ?>
<div class="tagged-item col-sm-<?php echo round((12 / $this->columns)); ?> col-md-<?php echo round((12 / $this->columns)); ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?><?php if ($counter > 0 and fmod($counter + 1, $this->columns) == 0) : echo ' last'; endif; ?>" itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
<?php $this->item = &$item; ?>
<a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid)); ?>" itemprop="url">
<h3 itemprop="name"><?php echo $this->escape($this->item->title); ?></h3>
<?php $images = json_decode($this->item->images); ?>
<img <?php if ($images->image_intro_caption) : echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_intro_caption) . '"'; endif; ?> src="<?php echo htmlspecialchars($images->image_intro); ?>" alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>" itemprop="thumbnailUrl" />
</a>
</div>
<?php $counter++; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment