-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbodyPostGrid.php
77 lines (72 loc) · 3.85 KB
/
bodyPostGrid.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
</div> <!-- kill the main container, we have our own here -->
<div id="postgrid" class="<?php echo $templateVars['postGrid']['class']; ?>">
<div class="container"><!-- other...main container?-->
<h3 class="debold"><?php echo $templateVars['postGrid']['title']; ?></h3>
<?php
$counter = 1;
foreach($posts as $post){
$postType = strtolower($post->category->name);
//find the post image
$tagExists = !(strpos($post->content, '<img class="headliner ') === FALSE);
if($tagExists){
$postImageTag = strstr($post->content, '/>', TRUE) . '/>';
$srcpos = strpos($postImageTag, 'src="/') + 6;
$quotpos = strpos($postImageTag, '"', $srcpos);
$postImage = '/' . substr($postImageTag, $srcpos, $quotpos - $srcpos);
}else{
$postImage = '/assets/img/template/headliner_default.png';
}
?>
<div class="post-preview topbar-<?php echo $postType; ?> bottombar-<?php echo $postType; ?>">
<a href="/post/<?php echo $post->guid; ?>">
<div class="content-preview">
<h3><?php echo $post->title; ?></h3>
<p class="byline">
<span class="label <?php echo $postType; ?>"><?php echo $postType; ?></span> <span class="datestamp"><?php echo date("F j, Y", $post->posted); ?></span>
</p>
<p><?php echo $post->headline; ?></p>
</div>
<div class="image-preview">
<img src="<?php echo $postImage; ?>" />
</div>
</a>
</div>
<?php
$counter++;
if($counter&1){
echo '<div class="clearfix"></div>';
}
}
?>
<div class="clearfix"></div>
<?php
if(isset($templateVars['pager'])){
echo '
<ul class="pager pull-right">';
if($templateVars['pager']['pageNum'] == 1){
echo'
<li class="disabled">
<a>← Newer</a>';
}else{
echo '
<li>
<a href="' . $templateVars['pager']['prevPageLink'] . '">← Newer</a>';
}
echo '
</li>';
if(!$templateVars['pager']['hasNext']){
echo '
<li class="disabled">
<a>Older →</a>';
}else{
echo '
<li>
<a href="' . $templateVars['pager']['nextPageLink'] . '">Older →</a>';
}
echo '
</li>
</ul>';
}
?>
</div><!--/main container2-->
<!--/postgrid is taken over by main template's /container-->