Skip to content

Commit 2ac9d0c

Browse files
committed
generate post and menus in their own helper due to separate your dynamic and php code from static and html code
1 parent eaa369a commit 2ac9d0c

File tree

1 file changed

+4
-36
lines changed

1 file changed

+4
-36
lines changed

index.php

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
include("helper.php");
2+
include("postHelper.php");
3+
include("menuHelper.php");
34
?>
45
<!DOCTYPE html>
56
<html lang="en">
@@ -63,16 +64,7 @@
6364
</button>
6465
<div class="collapse navbar-collapse" id="navbarResponsive">
6566
<ul class="navbar-nav ml-auto nav-pills">
66-
<?php
67-
$menus = menus();
68-
foreach($menus as $menu) {
69-
echo "<li class='nav-item'>";
70-
echo "<a class='nav-link' href='" . $menu['url'] . "'>";
71-
echo $menu['title'];
72-
echo "</a>";
73-
echo "</li>";
74-
}
75-
?>
67+
<?php echo menus(); ?>
7668
</ul>
7769
</div>
7870
</div>
@@ -83,31 +75,7 @@
8375
<div class="container">
8476
<div class="row">
8577
<div class="col-lg-8 col-md-10 mx-auto">
86-
<?php
87-
$posts = posts();
88-
foreach($posts as $post) {
89-
?>
90-
<div class="post-preview">
91-
<a href="./post.php">
92-
<h2>
93-
<?php
94-
echo $post['title'];
95-
?>
96-
</h2>
97-
</a>
98-
<div class="intro">
99-
<div class="clearfix">
100-
<p>
101-
<?php
102-
echo $post['intro'];
103-
?>
104-
</p>
105-
</div>
106-
</div>
107-
</div>
108-
<?php
109-
}
110-
?>
78+
<?php echo posts()?>
11179
<hr>
11280

11381
<div class="clearfix"></div>

0 commit comments

Comments
 (0)