File tree Expand file tree Collapse file tree 4 files changed +65
-64
lines changed Expand file tree Collapse file tree 4 files changed +65
-64
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
<?php
2
- include ("helper.php " );
2
+ include ("postHelper.php " );
3
+ include ("menuHelper.php " );
3
4
?>
4
5
<!DOCTYPE html>
5
6
<html lang="en">
63
64
</button>
64
65
<div class="collapse navbar-collapse" id="navbarResponsive">
65
66
<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 (); ?>
76
68
</ul>
77
69
</div>
78
70
</div>
83
75
<div class="container">
84
76
<div class="row">
85
77
<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 ()?>
111
79
<hr>
112
80
113
81
<div class="clearfix"></div>
Original file line number Diff line number Diff line change
1
+ <?php
2
+ include ("data.php " );
3
+
4
+ /**
5
+ * Get all menus
6
+ */
7
+ function menus () {
8
+ global $ menus ;
9
+
10
+ $ allMenus = null ;
11
+ if (isset ($ menus ) && count ($ menus ) > 0 ) {
12
+ foreach ($ menus as $ menu ) {
13
+ $ allMenus .= createEachMenuItem ($ menu );
14
+ }
15
+ }
16
+ return $ allMenus ;
17
+ }
18
+
19
+ function createEachMenuItem ($ menu ){
20
+ $ menuBody = "<li class='nav-item'> \n" ;
21
+ $ menuBody .= "<a class='nav-link' href=' " . $ menu ['url ' ] . "'> \n" ;
22
+ $ menuBody .= $ menu ['title ' ];
23
+ $ menuBody .= "</a> \n" ;
24
+ $ menuBody .= "</li> \n" ;
25
+ return $ menuBody ;
26
+
27
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+ include ("data.php " );
3
+
4
+ /**
5
+ * Get All Posts
6
+ */
7
+ function posts ()
8
+ {
9
+ global $ posts ;
10
+
11
+ $ allPosts = null ;
12
+ if (isset ($ posts ) && count ($ posts ) > 0 ) {
13
+ foreach ($ posts as $ post ) {
14
+ $ allPosts .= createEachPost ($ post );
15
+ }
16
+ }
17
+ return $ allPosts ;
18
+ }
19
+
20
+
21
+ function createEachPost ($ post ){
22
+
23
+ $ postBody = '<div class="post-preview"> ' ;
24
+ $ postBody .= '<a href="./post.php"> ' ;
25
+ $ postBody .= '<h2> ' .$ post ['title ' ].'</h2> ' ;
26
+ $ postBody .= '</a> ' ;
27
+ $ postBody .= '<div class="intro"> ' ;
28
+ $ postBody .= '<div class="clearfix"> ' ;
29
+ $ postBody .= '<p> ' .$ post ['intro ' ].'</p> ' ;
30
+ $ postBody .= '</div> ' ;
31
+ $ postBody .= '</div> ' ;
32
+ $ postBody .= '</div> ' ;
33
+ return $ postBody ;
34
+ }
You can’t perform that action at this time.
0 commit comments