timber / starter-theme

The "_s" for Timber: a dead-simple theme that you can build anything from
MIT License
812 stars 274 forks source link

how to use acf_fc_layout correctly to call the desired template #90

Closed emitaylor closed 8 months ago

emitaylor commented 4 years ago

I've read all the examples and searched the issues here but I can't get my head around how the ACF flexible content fields work via Timber, or how to use acf_fc_layout correctly.

So far I've got as far as spitting out all of the field content, but this includes the layout names which obviously I dont want:

{% if contenu.acf_fc_layout == "layout_homehero" %}
        {% include 'partial/flexible-layouts/homehero.twig' with {'homehero': layout} only %}
    {% elseif contenu.acf_fc_layout == 'layout_homebio' %}
        {% include 'partial/flexible-layouts/linkedreferences.twig' with { 'linkedreferences': layout.linkedreferences } only %}
    {% else %}
        {% include 'politiqueconfidentialite.twig'  %}
    {% endif %}

Ant the vars: object(WP_Post)#5027 (28) { ["ID"]=> int(585) ["post_author"]=> string(1) "1" ["post_date"]=> string(19) "2019-09-16 20:29:25" ["post_date_gmt"]=> string(19) "2019-09-16 18:29:25" ["post_content"]=> string(0) "" ["post_title"]=> string(10) "front-page" ["post_excerpt"]=> string(0) "" ["post_status"]=> string(7) "publish" ["comment_status"]=> string(6) "closed" ["ping_status"]=> string(6) "closed" ["post_password"]=> string(0) "" ["post_name"]=> string(10) "front-page" ["to_ping"]=> string(0) "" ["pinged"]=> string(0) "" ["post_modified"]=> string(19) "2019-09-17 18:07:39" ["post_modified_gmt"]=> string(19) "2019-09-17 16:07:39" ["post_content_filtered"]=> string(0) "" ["post_parent"]=> int(0) ["guid"]=> string(39) "http://www.starterwp.dev/?page_id=585" ["menu_order"]=> int(0) ["post_type"]=> string(4) "page" ["post_mime_type"]=> string(0) "" ["comment_count"]=> string(1) "0" ["filter"]=> string(3) "raw" ["status"]=> string(7) "publish" ["id"]=> int(585) ["slug"]=> string(10) "front-page" ["custom"]=> array(46) { ["inline_featured_image"]=> string(1) "0" ["_edit_last"]=> string(1) "1" ["_wp_page_template"]=> string(7) "default" ["_edit_lock"]=> string(12) "1568736459:1" ["contenu"]=> array(5) { [0]=> string(15) "layout_homehero" [1]=> string(14) "layout_gallery" [2]=> string(17) "layout_homeaction" [3]=> string(26) "layout_homecirconscription" [4]=> string(14) "layout_homebio" } ["_contenu"]=> string(19) "field_5d6ef6f86504d" ["contenu_0_bck_homehero"]=> string(3) "613" ["_contenu_0_bck_homehero"]=> string(19) "field_5d6ef7886504e" ["contenu_0_title_homehero"]=> string(17) "TITLE" ["_contenu_0_title_homehero"]=> string(19) "field_5d6ef88a6504f" ["contenu_0_catchphrase_homehero"]=> string(58) "catchphrase" ["_contenu_0_catchphrase_homehero"]=> string(19) "field_5d6ef8c165050" ["contenu_1_video_videogallery"]=> string(32) "[elfsight_facebook_feed id="1"] " ["_contenu_1_video_videogallery"]=> string(19) "field_5d710bd6d30e9" ["contenu_2_bck_pushhero"]=> string(3) "622" ["_contenu_2_bck_pushhero"]=> string(19) "field_5d6fdd85208c0" ["contenu_2_whitetitle_pushhero"]=> string(10) "MON ACTION" ["_contenu_2_whitetitle_pushhero"]=> string(19) "field_5d6fddb6208c1" ["contenu_2_bluetitle_pushhero"]=> string(13) "CONTRE LE GASPILLAGE" ["_contenu_2_bluetitle_pushhero"]=> string(19) "field_5d7017714913a" ["contenu_2_resume_pushhero"]=> string(0) "" ["_contenu_2_resume_pushhero"]=> string(19) "field_5d7017f14913b" ["contenu_2_btn1_pushhero"]=> string(21) "Interventions vidéos" ["_contenu_2_btn1_pushhero"]=> string(19) "field_5d70181f4913c" ["contenu_2_btn2_pushhero"]=> string(24) "Mes propositions" ["_contenu_2_btn2_pushhero"]=> string(19) "field_5d7018da4913d" ["contenu_2_btn3_pushhero"]=> string(38) "Mes questions écrites" ["_contenu_2_btn3_pushhero"]=> string(19) "field_5d7ce72b6ac87" ["contenu_3_bck_pushreverse"]=> string(3) "626" ["_contenu_3_bck_pushreverse"]=> string(19) "field_5d727794b1d18" ["contenu_3_title_pushreverse"]=> string(18) "AU QUOTIDIEN" ["_contenu_3_title_pushreverse"]=> string(19) "field_5d72779fb1d19" ["contenu_3_resume_pushreverse"]=> string(333) "Le Lorem Ipsum est simplement du faux texte employé dans la composition et la mise en page avant impression. Le Lorem Ipsum est le faux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen de polices de texte." ["_contenu_3_resume_pushreverse"]=> string(19) "field_5d7277ccb1d1a" ["wisiwyg_politiqueconfidentialite"]=> string(0) "" ["_wisiwyg_politiqueconfidentialite"]=> string(19) "field_5d6f08f90a0b3" ["contenu_4_bck_push"]=> string(3) "637" ["_contenu_4_bck_push"]=> string(19) "field_5d701a214913e" ["contenu_4_title_push"]=> string(6) "MA BIO" ["_contenu_4_title_push"]=> string(19) "field_5d701acd4913f" ["contenu_4_resume_push"]=> string(824) "On sait depuis longtemps que travailler avec du texte lisible et contenant du sens est source de distractions, et empêche de se concentrer sur la mise en page elle-même. L'avantage du Lorem Ipsum sur un texte générique comme 'Du texte. Du texte. Du texte.' est qu'il possède une distribution de lettres plus ou moins normale, et en tout cas comparable avec celle du français standard. De nombreuses suites logicielles de mise en page ou éditeurs de sites Web ont fait du Lorem Ipsum leur faux texte par défaut, et une recherche pour 'Lorem Ipsum' vous conduira vers de nombreux sites qui n'en sont encore qu'à leur phase de construction. Plusieurs versions sont apparues avec le temps, parfois par accident, souvent intentionnellement (histoire d'y rajouter de petits clins d'oeil, voire des phrases embarassantes)." ["_contenu_4_resume_push"]=> string(19) "field_5d701ae549140" ["contenu_4_linkbtn_push"]=> string(0) "" ["_contenu_4_linkbtn_push"]=> string(19) "field_5d701b1249141" ["contenu_4_textbtn_push"]=> string(0) "" ["_contenu_4_textbtn_push"]=> string(19) "field_5d701b2b49142" }

thank you in advance

Levdbas commented 8 months ago

Documented at https://timber.github.io/docs/v2/integrations/advanced-custom-fields/#flexible-content-field