-
Notifications
You must be signed in to change notification settings - Fork 0
/
single-devices.php
184 lines (146 loc) · 7.14 KB
/
single-devices.php
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
<?php
if (isset($_GET["profile"]) && !empty($_GET['profile'])) :
require(dirname(__FILE__) . "/single-devices-profile.php");
exit();
endif; ?>
<?php get_header(); ?>
<?php while (have_posts()) : the_post(); ?>
<?php if (has_post_thumbnail()) : ?>
<div class="" style="height: 450px; background-image: url(<?php the_post_thumbnail_url('large'); ?>); background-size: cover; background-position: center;"></div>
<?php endif; ?>
<div style="min-height: 100vh">
<div class="container mt-5">
<div class="row">
<div class="col">
<h1><?php the_title() ?></h1>
<?php the_content(); ?>
</div>
<div class="col-12 col-xl-4 col-md-6">
<div class="card p-3">
<h4 class="mb-3"> Technische Daten </h4>
<?php $cfields = get_post_custom() ?>
<table>
<tbody>
<?php foreach ($cfields as $key => $value) :
preg_match('/table_(.*)/', $key, $matches);
if (count($matches) > 0) :
$key = str_replace("table_", "", $key);
$key = str_replace("_", " ", $key);
?>
<tr>
<td class="pr-5 pb-3"><?php echo $key ?></td>
<?php if (is_array($value)) : ?><td class="pb-3"><?php echo join(', ', $value) ?></td>
<?php else : ?><td class="pb-3"><?php echo $value ?></td><?php endif; ?>
</tr>
<?php endif;
endforeach; ?>
<tbody>
</table>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col">
<h3>Dokumente</h3>
</div>
</div>
<!-- Betriebsanweisung -->
<?php
$betriebsanweisung_id = get_post_meta($post->ID, 'betriebsanweisung_attachment_id', true);
if (!empty($betriebsanweisung_id)) :
?>
<div class="row">
<div class="col-3">Betriebsanweisung</div>
<div class="col">
<a target="_blank" href="<?php echo wp_get_attachment_url($betriebsanweisung_id) ?>"><?php echo get_the_title($betriebsanweisung_id) ?></a>
</div>
</div>
<? endif; ?>
<!-- Datenblatt -->
<?php
$datenblatt_id = get_post_meta($post->ID, 'datenblatt_attachment_id', true);
if (!empty($datenblatt_id)) :
?>
<div class="row">
<div class="col-3">Datenblatt</div>
<div class="col">
<a target="_blank" href="<?php echo wp_get_attachment_url($datenblatt_id) ?>"><?php echo get_the_title($datenblatt_id) ?></a>
</div>
</div>
<?php endif; ?>
<!-- Bedienungsanleitung -->
<?php
$bedienungsanleitung_id = get_post_meta($post->ID, 'bedienungsanleitung_attachment_id', true);
if (!empty($bedienungsanleitung_id)) :
?>
<div class="row">
<div class="col-3">Bedienungsanleitung</div>
<div class="col">
<a target="_blank" href="<?php echo wp_get_attachment_url($bedienungsanleitung_id) ?>"><?php echo get_the_title($bedienungsanleitung_id) ?></a>
</div>
</div>
<?php endif; ?>
</div>
<div class="container mt-5">
<div class="row">
<div class="col">
<h3>Projekte mit diesem Gerät</h3>
</div>
</div>
<div class="row">
<?php
$tags = get_the_tags($post->ID);
$tags_string = $post->post_title . ",";
foreach ($tags as $tag) :
$tags_string .= $tag->slug . ",";
endforeach;
// echo $tags_string;
$args = array('tag' => $tags_string);
$wp_query_posts = new WP_Query($args);
?>
<?php if (!$wp_query_posts->have_posts()) : ?>
<div class="col">
Aktuell gibt es kein dokumentiertes Projekt zu diesem Gerät. Komm doch vorbei und tue etwas dagegen!
</div>
<?php else : ?>
<?php while ($wp_query_posts->have_posts()) : $wp_query_posts->the_post(); ?>
<div class="col-4 mb-5 d-flex flex-column" onclick="window.location.href = '<?php echo get_permalink(); ?>'" style="cursor: pointer;">
<?php if (has_post_thumbnail()) : ?>
<div class="" style="height: 250px; background-image: url(<?php echo get_the_post_thumbnail_url(); ?>); background-size: cover; background-position: center;"></div>
<?php else : ?>
<div class="" style="height: 250px; background-image: url(<?php echo get_template_directory_uri(); ?>/assets/images/image-missing.png); background-size: cover; background-position: center;"></div>
<?php endif; ?>
<div class="bg-white flex-fill p-2">
<h5 class="">
<?php the_title() ?>
</h5>
</div>
<div class="bg-white p-3 text-truncate text-wrap text-justify" style="max-height: 250px;">
<p>
<?php
if (has_excerpt()) :
the_excerpt();
else :
the_content();
endif;
?>
</p>
</div>
<div class="bg-white p-3 pt-auto" style="font-size: 0.72rem;">
<div class="text-secondary">von
<?php echo get_the_author() ?>
</div>
<div class="text-secondary">veröffentlicht am
<?php echo get_the_date() ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
</div>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>