Commit 5a6b5529 authored by Benthe Kuijpers's avatar Benthe Kuijpers
Browse files

Improve submenu

parent b74abd8f
{
"key": "group_605df11a2198d",
"title": "Submenu",
"fields": [
{
"key": "field_605df12f3fa42",
"label": "Submenu items",
"name": "submenu_items",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": 0,
"max": 0,
"layout": "table",
"button_label": "Add submenu",
"sub_fields": [
{
"key": "field_605df1383fa43",
"label": "Label",
"name": "label",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
},
{
"key": "field_605df1590d65f",
"label": "Anchor",
"name": "anchor",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"default_value": "",
"placeholder": "",
"prepend": "",
"append": "",
"maxlength": ""
}
]
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "page"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": true,
"description": "",
"modified": 1616769374
}
\ No newline at end of file
......@@ -5,10 +5,19 @@
<?php
if ( have_posts() ) :
if (!is_front_page()) { ?>
<div class="page-header <?php if (have_rows('submenu_items')) { echo 'page-header--submenu'; } ?>">
if (!is_front_page()) {
$has_sub_menu = false;
while ( have_rows('page_builder') ) : the_row();
if( get_row_layout() == 'anchor' ) {
$has_sub_menu = true;
}
endwhile; ?>
<div class="page-header <?php if ($has_sub_menu) { echo 'page-header--submenu'; } ?>">
<h1><?php echo get_the_title(); ?></h1>
<?php get_template_part('template-parts/submenu'); ?>
<?php if ($has_sub_menu) {
get_template_part('template-parts/submenu');
} ?>
</div>
<?php }
......
<div id="<?php the_sub_field('anchor'); ?>"></div>
\ No newline at end of file
<?php $anchor = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', get_sub_field('anchor')))); ?>
<div id="<?php echo $anchor; ?>"></div>
\ No newline at end of file
<?php
if (have_rows('submenu_items')) :
echo '<div class="submenu">';
echo '<div class="submenu__wrapper">';
while (have_rows('submenu_items')) : the_row();
echo '<a href="#' . get_sub_field('anchor') . '" class="text-link text-link--down">' . get_sub_field('label') . '</a>';
endwhile;
echo '</div>';
echo '</div>';
endif;
?>
\ No newline at end of file
<div class="submenu">
<div class="submenu__wrapper">
<?php
if( have_rows('page_builder') ):
while ( have_rows('page_builder') ) : the_row();
if( get_row_layout() == 'anchor' ):
$anchor = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', get_sub_field('anchor'))));
echo '<a href="#' . $anchor . '" class="text-link text-link--down">' . get_sub_field('anchor') . '</a>';
endif;
endwhile;
endif; ?>
</div>
</div>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment