-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmasterpage.html
More file actions
418 lines (340 loc) · 19.3 KB
/
masterpage.html
File metadata and controls
418 lines (340 loc) · 19.3 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ness PHP Framework | Docs</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="assets/fnt-aw/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!--Load highlightjs package -->
<link rel="stylesheet" href="assets/js/highlightjs/styles/vs2015.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<div class="wrapper">
<!-- Sidebar -->
<nav id="sidebar">
<div id="sidebar-header" class="text-center">
<br>
<a href="index.html" id="logo-area-link">
<img src="assets/img/nessphp_bordered.png" alt="Ness PHP Documentation" width="70%"/>
<h3>Ness PHP</h3>
<h4>Documentation</h4>
</a>
<a href="index.html" class="btn btn-light btn-sm" style="width: 100%;">
<i class="fa fa-angle-left" aria-hidden="true"></i> Back
</a>
</div>
<br>
<!--Load LATER-->
<div id="sidebar-loader" class="sidebar-contents">
</div>
</nav>
<div id="content">
<!--Nabvar:start-->
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<button id="sidebarCollapse" class="btn-circle">
<i class="fa fa-bars" aria-hidden="true"></i>
</button>
<ul class="nav navbar-nav">
<li class="nav-item">
<a href="index.html" class="navbar-text-header">
Ness PHP Framework
</a>
</li>
</ul>
<button class="btn-circle d-inline-block d-lg-none ml-auto" type="button" data-toggle="collapse" data-target="#headernav-links" aria-controls="headernav-links" aria-expanded="false" aria-label="Toggle Menu">
<i class="fa fa-ellipsis-v" aria-hidden="true"></i>
</button>
<div class="collapse navbar-collapse" id="headernav-links">
<ul class="nav navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link " href="https://nessphp.github.io/">
<i class="fa fa-terminal" aria-hidden="true"></i>
Ness PHP
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="https://github.com/nessphp/application">
<i class="fa fa-github" aria-hidden="true"></i>
GitHub
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="support.html">
<i class="fa fa-heart" aria-hidden="true"></i>
Support
</a>
</li>
</ul>
</div>
</div>
</nav>
<!--Nabvar:end-->
<!-- ========================content:start======================== -->
<div id="holder">
<span class="pageheader">Template Engine & Master Pages</span>
<br>
<div class="row">
<div class="col-lg-8">
<ul class="hash-toc">
<li>Contents
<ul>
<li><a href="#about">About Template Engine</a></li>
<li><a href="#newmasterpage">Create Master Pages</a></li>
<li><a href="#inheritance">Template Inheritance</a></li>
<li><a href="#logic">How Template Engine Works</a></li>
<li><a href="#telang">Template Engine Language</a></li>
<li><a href="#methods">Methods</a></li>
</ul>
</li>
</ul>
</div>
<!--Required Namespace -->
<div class="col-lg-4">
<div class="card bg-dark text-white">
<div class="card-header">Required Namespace</div>
<div class="card-body" >
<ul class="tree">
<li style="color:#28A745;">Ness
<ul>
<li style="color:#fff;">UI
<ul><li>Page</li></ul>
</li>
</ul>
</li>
</ul>
<hr>
<span><small>You can include this library to your code file by typing the below code;</small></span>
<br><br>
<span style="color:#3490CF;">use</span>
<span style="color:#28A745;">Ness\UI</span>\Page
</div>
</div>
</div>
<!--end: Required Namespace -->
</div>
<br><br>
<!--start: topic-->
<h4 id="about">About Ness PHP's Template Engine <small><a href="#content">#top</a></small></h4>
<p>
Ness PHP's master pages allows you to create layouts for your web pages in your application.It is designed to eliminate the need to write the same html code for each repetitive design every time.Once you design a template, you can easily relate it to all the pages and accelerate your coding experience to twice that. This topic can be thought of as the continuation of the 'View' topic you can read more about views <a href="views.html">Here</a>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="newmasterpage">Create New Master Page <small><a href="#content">#top</a></small></h4>
<p>
You can create unlimited master pages for your application for using them later with view files. All your master pages should be located in '<span class="ug-code ug-keyword">Template</span>' directory which can be found in Application root. For example you can create two master pages one for backend(admin panel) and one for front-end (user-area) and switch between them while creating new views using the master pages you have created.
<br><br>
Here is a simple example for a Master Page definition. Save this file as adminpanel_master.php in Template directory.
<pre>
<code class="html">
<!DOCTYPE html>
<html>
<head>
	<title>{@page_title} - Simple Blog</title>
	<link rel="stylesheet" type="text/css" href="<?= Ness\ContentManager::getStyleSheet("style.css");?>">
</head>
<body>
<div class="menu">
	<ul>
		<li>
			<a href="#">Dashboard</a>
			<a href="#">Profile</a>
			<a href="#">Create User</a>
			<a href="#">Edit Posts</a>
		<li>
	</ul>
<?php
	/**
	 * This line below must me available in all your master pages.
	 * echo $this->contents; means your content place holder. Your data in
	 * views will be loaded here.
	 */
	echo $this->contents;
?>
<div class="footer">
	<h4>(C) Ness Tutorials - Sinan SALIH </h4>
</body>
</html>
</code>
</pre>
As you can realise there is basic design for our admin panel with menu, footer and a code line like; <span class="ug-code ug-keyword">echo $this->contents;</span> this code snippet is required for the inheritance. When you create a new sub-view from the template all codes (HTML+PHP) in your View/viewfile.php will be parsed and placed in the line where $this->contents is printed.
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="inheritance">Template Inheritance <small><a href="#content">#top</a></small></h4>
<p>
Using templates in Ness PHP is extremely easy. Just create a new view file and specify the master page you have created.
<pre>
<code class="html">
<?php
$page = new Ness\UI\Page();
$page->setLayout('adminpanel_master.php');
$page->BeginContent();
?>
<!-- PAGE CONTENT STARTS -->
<!-- YOUR HTML/PAGE CONTENTS FOR THIS PAGE -->
<!-- PAGE CONTENT ENDS -->
<?php
$page->EndContent();
?>
</code>
</pre>
As you can use we are using adminpanel_master.php template file. All contents between <br>
<pre><code class="php">$page->BeginContent();</code></pre> and
<pre><code class="php">$page->EndContent();</code></pre> will be parsed and put in the template file
where the
<pre><code class="php">echo $this->contents;</code></pre> is defined in adminpanel_master.php
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="logic">How Template Engine Works <small><a href="#content">#top</a></small></h4>
<p>
<div class="text-center">
<img src="assets/img/telogic.png" width="70%"/>
</div>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="telang">Template Engine Language <small><a href="#content">#top</a></small></h4>
<p>
If you want to use template engine, you need to follow some rules. Some of them are like the ones below
<ol>
<li>
<span class="badge badge-success">Content Place Holder</span> Please do not forget to define and print <code>$this->contents</code> variable where you want to put your view's html contents.
</li>
<br><br>
<li>
<span class="badge badge-success">Define Parameters</span> If you want to set parameters between layouts and views, you need to type <code>{@parameter1}</code> in your layout file. You can set a value for your parameters by typing <code>$view_variable->SetParameter("parameter1", "my value is..");</code>
</li>
<br><br>
<li>
<span class="badge badge-success">Page Title</span> You can set a different title for every view. You can complete this task by setting a parameter but also if you type <code>echo $this->title;</code> on your template file you can use and set a title by SetTitle command
</li>
</ol>
</p>
<br>
<!--end: topic-->
<!--start: topic-->
<h4 id="methods">Methods <small><a href="#content">#top</a></small></h4>
<p>
<!---->
<h5>SetLayout</h5>
<pre><code class="php">$view->SetLayout(string $prm_file);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">Use a template file in your views with this command</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm_file String; File name of master page</td>
</tr>
</table><br><br><br>
<!---->
<h5>SetParameter</h5>
<pre><code class="php">$view::SetParameter(string $prm_name,string $prm_value );</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">Set content for parameter defined in template page.</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm_name String; Parameter name available in template<br>
$prm_value String; Value to set for the parameter</td>
</tr>
</table><br><br><br>
<!---->
<h5>SetParameterNull</h5>
<pre><code class="php">$view->SetParameterNull(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">Set null value to unused parameter in template files</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String; Parameter name</td>
</tr>
</table><br><br><br>
<!---->
<h5>SetTitle</h5>
if you do not use parameters for setting title you can use this function. Remember <span class="ug-code ug-folder"><?php echo $this->title; ?></span> must be defined in template.
<br><br>
<pre><code class="php">$view->SetTitle(string $title);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">Set a title for an inheritanced view</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Void</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$title String; Title set for the page</td>
</tr>
</table><br><br><br>
<!---->
<h5>insertWidget</h5>
<pre><code class="php">Page::insertWidget(string $prm);</code></pre>
<table class="code-desc">
<tr>
<td colspan="3">Include a widget from Application/Content/widget path</td>
</tr>
<tr>
<td>Return</td>
<td colspan="2">Object</td>
</tr>
<tr>
<td>Parameters</td>
<td colspan="2">$prm String; File name; ex: widget.html</td>
</tr>
</table><br><br><br>
<!---->
<h5>BeginContent() & EndContent()</h5>
<p>
Start and Finish content definitions for view files when using a template.
<pre><code class="html">
$view->BeginContent();
...
..
.
Contents Here
.
..
...
$view->EndContent();
</code></pre>
</p>
</p>
<br>
<!--end: topic-->
</div>
<!-- ========================content:end======================== -->
</div>
</div>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/nessphp.js"></script>
<script src="assets/js/highlightjs/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</body>
</html>