Skip to content

Commit

Permalink
Update sub-content.php
Browse files Browse the repository at this point in the history
You're checking to see if the story snippets array is set and then is greater than zero OR the story intro is set and story isn't nothing and then going on to try to get things from the snippets array even though that might be empty due to the intro being filled.

Have put another check in later to ensure that the array actually exists and isn't blank as the other side to your check on line 56.

Should probably be two different loops.
  • Loading branch information
Flowdeeps authored Feb 22, 2017
1 parent e376726 commit 9baafb8
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions php-snippets/sub-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,26 @@
print "
".$story['intro'];
}
// go through the snippets in the array and print text or image
foreach($story['snippets'] as $snippetid => $snippetvalues) {
if(isset($snippetvalues['src'])) {
print "
<figure class=\"cms-image ".$snippetvalues['align']."\" style=\"max-width: 360px;\">
<img src=\"".$snippetvalues['src']."\" style=\"max-width: 100%\" rel=\"resizable\" alt=\"\" />
<figcaption>".$snippetvalues['title']."
<span class=\"photographer\">
".$snippetvalues['credits']."
</span>
</figcaption>
</figure>";
}
if(isset($snippetvalues['text'])) {
print "
".$snippetvalues['text'];
}
} // foreach($story['snippets']
// go through the snippets in the array and print text or image
if(isset($story['snippets']) && count($story['snippets']) > 0) {
foreach($story['snippets'] as $snippetid => $snippetvalues) {
if(isset($snippetvalues['src'])) {
print "
<figure class=\"cms-image ".$snippetvalues['align']."\" style=\"max-width: 360px;\">
<img src=\"".$snippetvalues['src']."\" style=\"max-width: 100%\" rel=\"resizable\" alt=\"\" />
<figcaption>".$snippetvalues['title']."
<span class=\"photographer\">
".$snippetvalues['credits']."
</span>
</figcaption>
</figure>";
}
if(isset($snippetvalues['text'])) {
print "
".$snippetvalues['text'];
}
} // foreach($story['snippets']
}
print "
</div><!-- / .text -->
</div><!-- / .row -->";
Expand Down

0 comments on commit 9baafb8

Please sign in to comment.