Skip Navigation

[Resolved] Using the_ddlayout inside page.php template

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use Layouts to design the content area of my site only. My theme is not integrated. If I add the_ddlayout(), Layouts takes over the entire site. How should I modify my site PHP templates to allow Layouts to design the content area only?

Solution:
Only include the_ddlayout() if you want Layouts to take over the design of your entire site. If not, a more standard WordPress PHP template is appropriate:

if ( have_posts() ) : while ( have_posts() ) : the_post();
// Post Content here
endwhile; else :
//your theme's "No posts found" template call
endif;

Also you should not return "true" in this filter unless you want Layouts to take over the design of the entire site:

add_filter( 'ddl-is_integrated_theme', 'theme_is_integrated_with_layouts' );
function theme_is_integrated_with_layouts() {
    return false;
}

Either return false, or remove the filter entirely. By default, Layouts will not be integrated if you remove the filter.

Relevant Documentation: https://toolset.com/documentation/user-guides/layouts-theme-integration/

This support ticket is created 6 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 11 replies, has 2 voices.

Last updated by Ole Andreas Vekve 6 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#530588

I am trying to add a layout to my page.php template. However I have forgotten how it should be done when I DONT want to use layouts to customize the whole page template.

I have made a post type called Ansatte. This post type should have the employers, which are currently 2. For this post type I have made an Archive page and Views. I have made them both because I was not sure which I should make when i ONLY wanted to include the "the_ddlayout" into one particular page. This is because they only want to show employers in one page, and no archieve page is currently needed.

In my page template I have added the following:

<?php the_ddlayout( 'default-layout' ); ?>

This is what I used last time I got this to work.

When I visit my page nothing comes up, and the content is only repeated infinity times.

Hope this explains it,

How do I solve this problem?

hidden link

#530621

Hi there,

It sounds like you want to use Layouts for the content area of this page, but you don't want to take over the design of the entire page. This is how Layouts works with any theme that is not "integrated", meaning that Layouts only affects the content area of your post or page and not the main site design, like headers and footers and sidebars and so forth. If this sounds like what you want, then you do not need to include "the_ddlayout()" anywhere in your page template. Your page.php file should instead call "the_post()" like usual, something like this:

if ( have_posts() ) : while ( have_posts() ) : the_post();
// Post Content here
endwhile; else :
//your theme's "No posts found" template call
endif;

Only include the_ddlayout() if you want to take over the entire site design. Let me know if you have questions about this.

#530984

Hello,

Currently I need the content area of this page to be shown. That`s why I am using a page template and not archive page.

It looks something like this:

<?php while ( have_posts() ) : the_post(); ?>
 
<?php the_content('readmore', true); ?>
               
<?php the_ddlayout( 'default-layout' ); ?>

<?php endwhile; // end of the loop. ?>

How can I solve this problem?

#531022
Screen Shot 2017-05-31 at 11.26.22 AM.png

Delete this:

<?php the_ddlayout( 'default-layout' );  ?>

Then edit the Layout you have applied to your page. Add a Post Content cell or add the post body to a Visual Editor cell. Screenshot attached showing the Post Content cell.

#531039

Okay, that sounds easy.

I have now edited my page template into the following:

<?php while ( have_posts() ) : the_post(); ?>

<?php the_content('readmore', true); ?>

<?php endwhile; // end of the loop. ?>

I have made a Layout called Page Layout Content Only and set up Post Content. So at this point it shows the post content and not the archive part.

I added a row below with WordPress Archive. However, this does not appear on my page.

Any ideas?

#531072

Hi, I'm not sure I understand what you're trying to accomplish. It sounds like you want to include the content of a page, plus a WordPress Archive, on a single post. Toolset isn't designed to combine these two pieces of functionality - they're mutually exclusive. WordPress doesn't typically include post content and archives on the same page either.

I think the best approach will be to use a View instead of a WordPress Archive cell here. This View can be designed to display the same posts you would expect to see in your WordPress Archive. For example, if you want to show a list of Pages here, create your View to show Pages ordered by descending date. This will mimic the functionality of a WordPress Archive and allow you to combine the two features on a single post or page.

Please let me know if this does not make sense, and I can explain further. Thanks!

#531094

Yes, I would like to include the content of a page, plus a WordPress Archive.

I have already made a View for the post types, but not sure how to include it. It is suppose to be ordered by post date, descending.

I have inserted the View in Page Layout Content Only. Still shows nothing.

Not sure if I understand it correctly.

I used to do this on all of my pages earlier when I handcoded it, so it`s tempting to do the same now. But since I pay for this now I was hoping there would be a easier solution.

The idea is using content of a page so the user edit it the same way. None of my customers have enough competence to use layout or the other tools to edit their content. Easy editable content + an easy way to add employers which are updated automaticly to the same page.

Looking forward to hear from you again 🙂

#531450

Can you share the shortcode you have used to place your View in the page? Any screenshots you can share that show your View settings and Layouts structure will be helpful.

#531472
Page.jpg
Page Layout Content Only.jpg
Layouts.jpg

Okay, I post my screenhosts below.

Hope they explain it,

Thanks,

#531525

Okay I'll need to take a look at your wp-admin area to understand why this isn't working as expected. I would like to create a clone of your site using the Duplicator plugin, so I can install it locally and run tests without affecting your live site. If that is okay, please provide login credentials in the private reply fields here.

#535248

Hi, the main issue I see is in your functions.php file. As I understand it, you do not want to integrate your theme with Layouts. You want Layouts to be used only on the content of this page. Since your theme is not integrated with Layouts, so you should not use the ddl-is_integrated_theme hook and function:

add_filter( 'ddl-is_integrated_theme', 'theme_is_integrated_with_layouts' );
function theme_is_integrated_with_layouts() {
    return true;
}

Please delete this code so that Layouts understands not to take over the design of your entire page. Then your View should work as expected. Let me know how it goes, or if you need additional information about this:
https://toolset.com/documentation/user-guides/layouts-theme-integration/

#537304

Thank you,

That solves the problem,

Have a nice day,

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.