-
Notifications
You must be signed in to change notification settings - Fork 1
/
head.inc
169 lines (113 loc) · 4.89 KB
/
head.inc
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
<?php
/**
* Demo site header include file (HTML5)
*
* Note that this file has nothing to do with ProcessWire. We just split our common
* header and footer markup into separate files (head.inc and foot.inc) like this,
* since it was common to all of our templates.
*
*/
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $page->get("headline|title"); ?></title>
<meta name="description" content="<?php echo $page->summary; ?>" />
<meta name="generator" content="ProcessWire <?php echo $config->version; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/main.css" />
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/ie.css" />
<![endif]-->
<script type="text/javascript" src="<?php echo $config->urls->templates?>scripts/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo $config->urls->templates?>scripts/main.js"></script>
<!--
This website is powered by ProcessWire CMF/CMS.
ProcessWire is a free open source content management framework licensed under the GNU GPL.
ProcessWire is Copyright 2012 by Ryan Cramer / Ryan Cramer Design, LLC.
Learn more about ProcessWire at: http://processwire.com
-->
</head>
<body>
<p id='bgtitle'><?php
// print the section title as big faded text that appears near the top left of the page
echo $page->rootParent->title;
?></p>
<div id="masthead" class="masthead">
<div class="container">
<a href='<?php echo $config->urls->root; ?>'><p id='logo'>ProcessWire</p></a>
<ul id='topnav'><?php
// Create the top navigation list by listing the children of the homepage.
// If the section we are in is the current (identified by $page->rootParent)
// then note it with <a class='on'> so we can style it differently in our CSS.
// In this case we also want the homepage to be part of our top navigation,
// so we prepend it to the pages we cycle through:
$homepage = $pages->get("/");
$children = $homepage->children;
$children->prepend($homepage);
foreach($children as $child) {
$class = $child === $page->rootParent ? " class='on'" : '';
echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>";
}
?></ul>
<ul id='breadcrumb'><?php
// Create breadcrumb navigation by cycling through the current $page's
// parents in order, linking to each:
foreach($page->parents as $parent) {
echo "<li><a href='{$parent->url}'>{$parent->title}</a> > </li>";
}
?></ul>
<h1 id='title'><?php
// The statement below asks for the page's headline or title.
// Separating multiple fields with a pipe "|" returns the first
// one that has a value. So in this case, we print the headline
// field if it's there, otherwise we print the title.
echo $page->get("headline|title");
?></h1>
<form id='search_form' action='<?php echo $config->urls->root?>search/' method='get'>
<input type='text' name='q' id='search_query' value='<?php echo htmlentities($input->whitelist('q'), ENT_QUOTES, 'UTF-8'); ?>' />
<button type='submit' id='search_submit'>Search</button>
</form>
<?php
// Grab a random image from the homepage and display it.
// Note that $homepage was loaded above where we generated the top navigation.
if(count($homepage->images)) {
$image = $homepage->images->getRandom();
$thumb = $image->size(232, 176);
echo "<a href='{$image->url}'><img id='photo' src='{$thumb->url}' alt='{$thumb->description}' width='{$thumb->width}' height='{$thumb->height}' /></a>";
}
?>
</div>
</div>
<div id="content" class="content">
<div class="container">
<div id="sidebar">
<?php
// Output subnavigation
//
// Below we check to see that we're not on the homepage, and that
// there are at least one or more pages in this section.
//
// Note $page->rootParent is always the top level section the page is in,
// or to word differently: the first parent page that isn't the homepage.
if($page->path != '/' && $page->rootParent->numChildren > 0) {
// We have determined that we're not on the homepage
// and that this section has child pages, so make navigation:
echo "<ul id='subnav' class='nav'>";
foreach($page->rootParent->children as $child) {
$class = $page === $child ? " class='on'" : '';
echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>";
}
echo "</ul>";
}
?>
<div class='sidebar_item'>
<?php
// if the current page has a populated 'sidebar' field, then print it,
// otherwise print the sidebar from the homepage
if($page->sidebar) echo $page->sidebar;
else echo $homepage->sidebar;
?>
</div>
</div><!--/sidebar-->
<div id="bodycopy">