Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #207504

    I am using the layout builder in Enfold and would like to repeat layout and content on all of my pages. Said another way, I have 13 sections on each page (created using the Avia Layout Builder). The main content section of each page will change but content in the other 12 sections will be the same for every page. Is there a way to create a template and then include that template (with content) after the main content on each page?

    My thought was to create a dedicated page X for the content that will be the same on each page Y and then modify my templates to include the content from page X under the content of page Y.

    #207528

    Hey Vada!

    This is what you can do. Please switch your theme to debug mode. Edit function.php, find this code:

    if(isset($avia_config['use_child_theme_functions_only'])) return;

    Below, add this code:

    //set builder mode to debug
    add_action('avia_builder_mode', "builder_set_debug");
    function builder_set_debug()
    {
    return "debug";
    }

    You will be able to see the actual shortcode below the builder. Copy the shortcode that you want to place after each content.

    Best regards,
    Ismael

    #207572

    Thanks for the debug code. The problem with the approach you gave is that the editor will have to update every page in the site when a change needs to be made. Since the content in this portion should remain identical on all pages I’d much prefer to create a page that is used as an include file and then modify the template to include that file. This way the editor can make the change once and it will apply to all pages that use the template.

    Can you tell me how to get access to the layout builder content of a page by page ID so I can include it in my template file? For a normal page (created without using the avia layout builder) I could use the following code, but for pages that use the builder this code returns empty.

    
    <?php
    $je_include = get_pages('include=270');
    $je_content = apply_filters('the_content',$je_include[0]->post_content);
    echo $je_content;
    ?>
    

    Update: I copied and pasted the shortcodes from the advanced layout editor into the default editor. After doing so I was able to include the content using the above code. Example here: http://heartland.estlandpreview2.com/about/

    Content below the bright red line was included from my page called “Content Under Page”. I would still rather be able to call the content in the avia layout builder instead of having to create it in the layout builder and then copy/paste into the default editor. That is too many steps for the average user to remember.

    Also, I notice that my code (written in the page.php file of my child theme) only applies to pages that are using the default editor. Pages using the layout builder do not show the extra content. For example, the first page below uses the default editor and shows the additional content. The second page uses the layout builder and does not. Both pages are using the default template (page.php).

    http://heartland.estlandpreview2.com/about/ – default editor, shows additional content
    http://heartland.estlandpreview2.com/windows/ – layout builder editor, does not show additional content

    • This reply was modified 10 years, 3 months ago by Estland.
    #208255

    Hi!

    The advanced layout builder is at its core just a visual way to add shortcodes to a page. The content isn’t stored across any kind of templating system where it can be accessed outside of an individual page so what you are looking to do isn’t possible.

    Creating a custom page template is doable but the advanced layout builder doesn’t use the page.php whenever you use an element that has a full width attribute (layerslider, full width masonry etc) and instead uses the template-builder.php file.

    Best regards,
    Devin

    #804014

    You can get the content from page postmeta:

    $post_id = 270;
    $includecontent = apply_filters('avia_builder_precompile', get_post_meta($post_id, '_aviaLayoutBuilderCleanData', true));
    $includecontent = apply_filters('the_content', $includecontent);
    $includecontent = apply_filters('avf_template_builder_content', $includecontent);
    echo $includecontent;
    #804309

    Hi @jaripp,

    Thanks for sharing, much appreciated :-)

    Best regards,
    Rikard

    #825118

    … or you can use my repeatable content plugin. :-)

    https://habenicht.io/produkte/enfold-repeatable-content/

    • This reply was modified 6 years, 8 months ago by mrdonthave.
    #826793

    Hi mrdonthave,

    Thanks for that :-)

    Best regards,
    Rikard

    #1253274

    Wow I think this is a must have feature! for some of my clients. It is important that the content is not included in Sitemap and Google Search…

    #1253396

    Hey Rafíyel,

    This may be something that can be considered in the future.

    Best regards,
    Jordan Shannon

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Creating content that is included on each page’ is closed to new replies.