Two things really.
Really appreciate any guidance on this, been working hard for nights, can't get anything to work :(
<?php
// get all pages
$pages = new TFW_Navigation($pageNav);
$pages = $pages->getNavigation();
foreach ($pages as $index => $topPage)
{
$children = $topPage->getChildren(null,true);
if (!empty($children)) {
foreach($children as $child) {
?>
<article class="<?=$child->ext_column_1 ?>">
<a href="<?= $child->url ?>" class='article-border'>
<img src="<?=$child->ext_column_2 ?>" alt="">
<header>
<h3>
<?= $child->ext_column_3 ?>
</h3>
</header>
<footer>
<p>
<?php echo date("d F Y", strtotime($child->last_modified))."<span class='sprite article-link'></span>" ?>
</p>
</footer>
</a>
</article>
<?php
}
}
}
?>
If more information is needed, please let me know.
Thanks, Barry
Add a break
statement.
foreach($children as $childIndex => $child) {
if ($childIndex > 8) {
break;
}
...
}
$firstEight = array_slice($children, 0, 8); // First 8 items
$sql = "SELECT * FROM table WHERE x = y ORDER BY last_modified ASC";
and also you can limit the results from sql .
$sql = "SELECT * FROM table WHERE x = y ORDER BY last_modified ASC LIMIT 0,8";
// Using
<?php
// get all pages
$pages = new TFW_Navigation($pageNav);
$pages = $pages->getNavigation();
foreach ($pages as $index => $topPage)
{
$children = $topPage->getChildren(null,true);
$firstEight = array_slice($children, 0, 8);
if (!empty($firstEight)) {
foreach($firstEight as $child) {
?>
<article class="<?=$child->ext_column_1 ?>">
<a href="<?= $child->url ?>" class='article-border'>
<img src="<?=$child->ext_column_2 ?>" alt="">
<header>
<h3>
<?= $child->ext_column_3 ?>
</h3>
</header>
<footer>
<p>
<?php echo date("d F Y", strtotime($child->last_modified))."<span class='sprite article-link'></span>" ?>
</p>
</footer>
</a>
</article>
<?php
}
}
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.