Skip to content

Instantly share code, notes, and snippets.

@annelyse
Last active January 9, 2023 12:36
Show Gist options
  • Save annelyse/db58cb2affa6178c6256c008a1be0902 to your computer and use it in GitHub Desktop.
Save annelyse/db58cb2affa6178c6256c008a1be0902 to your computer and use it in GitHub Desktop.
[
{
"key": "group_63b2d05e0d423",
"title": "Boutons",
"fields": [
{
"key": "field_63b4309ced8ef",
"label": "Ouvrir un panneau ou un lien ?",
"name": "button__type",
"aria-label": "",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "33.333",
"class": "",
"id": ""
},
"choices": {
"link": "lien",
"panel": "panneau"
},
"default_value": "link",
"return_format": "array",
"allow_null": 0,
"other_choice": 0,
"layout": "vertical",
"save_other_choice": 0
},
{
"key": "field_63b430f9ed8f0",
"label": "Panneau à ouvrir :",
"name": "button__panel",
"aria-label": "",
"type": "checkbox",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_63b4309ced8ef",
"operator": "==",
"value": "panel"
}
]
],
"wrapper": {
"width": "33.3333",
"class": "",
"id": ""
},
"choices": {
"offCanvasContact": "contact"
},
"default_value": [],
"return_format": "value",
"allow_custom": 0,
"layout": "horizontal",
"toggle": 0,
"save_custom": 0
},
{
"key": "field_63b2d07f0d52d",
"label": "Lien",
"name": "button__link",
"aria-label": "",
"type": "link",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_63b4309ced8ef",
"operator": "==",
"value": "link"
}
]
],
"wrapper": {
"width": "33.33",
"class": "",
"id": ""
},
"return_format": "array"
},
{
"key": "field_63b438edb3dcc",
"label": "Texte du bouton",
"name": "button__label",
"aria-label": "",
"type": "text",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_63b4309ced8ef",
"operator": "==",
"value": "panel"
}
]
],
"wrapper": {
"width": "33.33",
"class": "",
"id": ""
},
"default_value": "",
"maxlength": "",
"placeholder": "",
"prepend": "",
"append": ""
},
{
"key": "field_63b43aa970c16",
"label": "Apparence du bouton",
"name": "",
"aria-label": "",
"type": "accordion",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"open": 0,
"multi_expand": 0,
"endpoint": 0
},
{
"key": "field_63b2d0b50d52e",
"label": "Couleur du bouton",
"name": "button__color",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "33.33",
"class": "",
"id": ""
},
"choices": {
"primary": "bleu foncé",
"secondary": "bleu clair",
"bonus": "bleu très clair",
"light": "blanc",
"transparent": "transparent"
},
"default_value": false,
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"ui": 0,
"ajax": 0,
"placeholder": ""
},
{
"key": "field_63b2dcc71435c",
"label": "Pictogramme",
"name": "button__icon",
"aria-label": "",
"type": "select",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "33.33",
"class": "",
"id": ""
},
"choices": {
"none": "Aucune",
"tchat": "chat",
"right-arrow": "Flèche"
},
"default_value": "none",
"return_format": "value",
"multiple": 0,
"allow_null": 0,
"ui": 0,
"ajax": 0,
"placeholder": ""
},
{
"key": "field_63b2dd371435d",
"label": "Affichage du pictogramme à :",
"name": "button__iconPosition",
"aria-label": "",
"type": "radio",
"instructions": "",
"required": 0,
"conditional_logic": [
[
{
"field": "field_63b2dcc71435c",
"operator": "!=",
"value": "none"
}
]
],
"wrapper": {
"width": "33.33",
"class": "",
"id": ""
},
"choices": {
"left": "Gauche",
"right": "Droite"
},
"default_value": "",
"return_format": "value",
"allow_null": 0,
"other_choice": 0,
"layout": "vertical",
"save_other_choice": 0
}
],
"location": [
[
{
"param": "post_type",
"operator": "==",
"value": "post"
}
]
],
"menu_order": 0,
"position": "normal",
"style": "default",
"label_placement": "top",
"instruction_placement": "label",
"hide_on_screen": "",
"active": false,
"description": "",
"show_in_rest": 0
}
]
{% set buttonsArray = mypost.buttons %}
{% if buttonsArray %}
<div class="btn-toolbar">
{% for button in buttonsArray %}
{# is there an icon ? #}
{% set is_btn_icon = button.button__icon == 'none' %}
{% if button.button__type.value == 'link' %}
<a href="{{ button.button__link.url}}" target="{{ button.button__link.target}}" class="btn btn-{{ button.button__color}} {% if not is_btn_icon %}icon-on-{{button.button__iconPosition}}{% endif %}">
{{button.button__link.title}}
{% if not is_btn_icon %} <svg class="icon"><use xlink:href="#icon-{{button.button__icon}}"></use></svg>{% endif %}
</a>
{% endif %}
{% if button.button__type.value == 'panel' %}
<button type="button" data-bs-target="#offCanvasContact"
data-bs-toggle="offcanvas"
role="button"
aria-controls="{{button.button__panel}}" class="btn btn-{{ button.button__color}} {% if not is_btn_icon %}icon-on-{{button.button__iconPosition}}{% endif %}">
{{button.button__label}}
{% if not is_btn_icon %} <svg class="icon"><use xlink:href="#icon-{{button.button__icon}}"></use></svg>{% endif %}
</button>
{% endif %}
{% endfor %}
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment