This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate-overzichtspagina.php
107 lines (71 loc) · 2.05 KB
/
template-overzichtspagina.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
<?php
/**
* Template Name: Overzichtspagina
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
$context = Timber::context();
$timber_post = new Timber\Post();
$context['post'] = $timber_post;
$context['overview'] = overviewpage_get_items();
// Gerelateerde content metablocks
if ( 'ja' === get_field( 'gerelateerde_content_toevoegen' ) ) {
$context['related'] = related_block_get_data();
}
// Spotlight blocks
$spotlightblocks = spotlight_block_get_data();
if ( $spotlightblocks ) {
$context['spotlight'] = $spotlightblocks;
}
// Inleiding
if ( get_field( 'post_inleiding' ) ) {
$intro = get_field( 'post_inleiding' );
$context['intro'] = wpautop( $intro );
}
Timber::render( [ 'overview.html.twig', 'page.twig' ], $context );
//========================================================================================================
function overviewpage_get_items() {
global $post;
$return = array();
$thisid = get_the_id();
if ( 'automatic' === get_field( 'overzichtspagina_method', $thisid ) ) {
// automagische selectie
$contenttypes = get_field( 'contenttypes', $thisid );
$args = [
'post_type' => $contenttypes,
'posts_per_page' => - 1,
'post_status' => 'publish',
];
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
$item = array();
$item = prepare_card_content( $post );
$return['items'][] = $item;
}
}
} else {
// handmagische selectie
$items = get_field( 'overzichtspagina_content_block_items', $thisid );
if ( $items ) {
foreach ( $items as $post ):
$item = array();
setup_postdata( $post );
$item = prepare_card_content( $post );
$return['items'][] = $item;
endforeach;
}
}
wp_reset_query();
/*
*
echo '<pre>';
var_dump( $return );
echo '</pre>';
*/
return $return;
}
//========================================================================================================