Skip Navigation

[Resolved] Integrating Toolset with the X Theme

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

Problem:
How can I integrate Layouts Plugin in X Theme?

Solution:
It is not easy, beccause that Theme does not follow the WordPress Template hierarchy directly.

What you can do is:

1. Integrate the Layouts Call to index.php and respective page.php of the theme:

if ( defined( 'WPDDL_VERSION' ) && is_ddlayout_assigned() ) : // if Layouts Plugin is active and a layout is assigned
 
        the_ddlayout( );
 
    else: // if not use the normal WP loop
x_get_view( x_get_stack(), 'wp', 'page' ); 
endif;?>

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

This support ticket is created 7 years, 9 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 8 replies, has 2 voices.

Last updated by alexandreT 7 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#412682
Screen Shot 2016-07-02 at 5.58.17 PM.png

Hi there!

I'm really looking forward to see what Toolset can do. I'm a big fan of the X Theme and so I was wondering since it's one of the most popular themes out there why there was no plugin for integration for this very popular theme yet? Is it in the works?

So I have been trying to integrate Toolset manually. I created a Child Theme and started going through the different php files. Here is where they stand and I'm sure I'm doing something wrong.

From the Child theme views/renew

WP-SINGLE.PHP:

<?php

// =============================================================================
// VIEWS/RENEW/WP-SINGLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Renew.
// =============================================================================

$fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );

?>

<?php get_header(); ?>
  
  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">
      <?php the_ddlayout( 'default-layout' ); ?>

    </div>

    <?php if ( $fullwidth != 'on' ) : ?>
      <?php get_sidebar(); ?>
    <?php endif; ?>

  </div>

<?php get_footer(); ?>

WP-PAGE.PHP:

<?php

// =============================================================================
// VIEWS/RENEW/WP-PAGE.PHP
// -----------------------------------------------------------------------------
// Single page output for Renew.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">
    	<?php the_ddlayout( 'default-layout' ); ?>

    </div>

    <?php get_sidebar(); ?>

  </div>

<?php get_footer(); ?>

WP-INDEX.PHP

<?php

// =============================================================================
// VIEWS/RENEW/WP-INDEX.PHP
// -----------------------------------------------------------------------------
// Index page output for Renew.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">
    	<?php the_ddlayout( 'default-layout' ); ?>

    </div>

    <?php get_sidebar(); ?>

  </div>

<?php get_footer(); ?>

and finally VIEWS/GLOBAL/_INDEX.PHP :

<?php

// =============================================================================
// VIEWS/GLOBAL/_INDEX.PHP
// -----------------------------------------------------------------------------
// Includes the index output.
// =============================================================================

$stack = x_get_stack();

if ( is_home() ) :
  $style     = x_get_option( 'x_blog_style' );
  $cols      = x_get_option( 'x_blog_masonry_columns' );
  $condition = is_home() && $style == 'masonry';
elseif ( is_archive() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_archive() && $style == 'masonry';
elseif ( is_search() ) :
  $condition = false;
endif;

?>

<?php if ( $condition ) : ?>

  <?php x_get_view( 'global', '_script', 'isotope-index' ); ?>

  <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">

    <?php if ( have_posts() ) : ?>
      <?php while ( have_posts() ) : the_post(); ?>
        <?php
      the_ddlayout( 'default-layout' );
    ?>

  </div>

<?php else : ?>

  <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
      <?php
      the_ddlayout( 'default-layout' );
    ?>

Can you help me find out what I'm doing wrong?

#412745

You need to replace the whole Loop.
The Loop usually starts with something like "if ( have_posts()" and ends with "endif;"

I can see from your above code that you did not correctly replace the Loop.
You can see the instructions here:
https://toolset.com/documentation/user-guides/layouts-theme-integration/

A more dynamic principle is elaborated here:
https://toolset.com/forums/topic/layouts-theme-integration-with-pcm-page-builder-theme/

Regarding integrating the X-Theme I will let chime in a Developer once all Issues of this Ticket are solved.

#412841

Hi Beda,

Here is my current code. I'm still getting the error message...

<?php

// =============================================================================
// VIEWS/RENEW/WP-INDEX.PHP
// -----------------------------------------------------------------------------
// Index page output for Renew.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">

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

    </div>

    <?php get_sidebar(); ?>

  </div>

<?php get_footer(); ?>
<?php

// =============================================================================
// VIEWS/RENEW/WP-PAGE.PHP
// -----------------------------------------------------------------------------
// Single page output for Renew.
// =============================================================================

?>

<?php get_header(); ?>

  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">

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

  </div>

<?php get_footer(); ?>
<?php

// =============================================================================
// VIEWS/RENEW/WP-SINGLE.PHP
// -----------------------------------------------------------------------------
// Single post output for Renew.
// =============================================================================

$fullwidth = get_post_meta( get_the_ID(), '_x_post_layout', true );

?>

<?php get_header(); ?>
  
  <div class="x-container max width offset">
    <div class="<?php x_main_content_class(); ?>" role="main">

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

  </div>

<?php get_footer(); ?>
<?php

// =============================================================================
// VIEWS/GLOBAL/_INDEX.PHP
// -----------------------------------------------------------------------------
// Includes the index output.
// =============================================================================

$stack = x_get_stack();

if ( is_home() ) :
  $style     = x_get_option( 'x_blog_style' );
  $cols      = x_get_option( 'x_blog_masonry_columns' );
  $condition = is_home() && $style == 'masonry';
elseif ( is_archive() ) :
  $style     = x_get_option( 'x_archive_style' );
  $cols      = x_get_option( 'x_archive_masonry_columns' );
  $condition = is_archive() && $style == 'masonry';
elseif ( is_search() ) :
  $condition = false;
endif;

?>

<?php if ( $condition ) : ?>

  <?php x_get_view( 'global', '_script', 'isotope-index' ); ?>

  <div id="x-iso-container" class="x-iso-container x-iso-container-posts cols-<?php echo $cols; ?>">

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

  </div>

<?php else : ?>

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

<?php pagenavi(); ?>
#412921

May I ask why that theme does not use native WordPress tempalte names?
A Single Post Template is called single.php, not wp-single.php
And so on.

Can you head to Layouts > New > create a layout > Change how this Layout is used and assign it to a content?
Can you head to Posts/Page/Custom Post > Edit > Layout and assign a Layout you created?

If these things work, it's just an error message that we need to deal with.

Your Theme's Loop is very very specific.

A short test you can do is to create a Template named page-layouts.php.

Insert this Code in it:

<?php
/*
Template Name: Layouts page template
*/
get_header('layouts'); ?>

    <?php if ( function_exists( 'the_ddlayout' ) ) : ?>

    	 <?php the_ddlayout(); ?>

    <?php else: ?>

        <h1>
        	<?php _e('This template requires the Drag and Drop Layout plugin.', 'your_theme'); ?>
        </h1>

    <?php endif; ?>


<?php get_footer('layouts');?>

Does it work now?

#413132

Hi Beda, here's what I refered to:
hidden link

Tried putting the page-layouts.php in /global and /renew but still getting the integration warning message

#413229

Well, it seems that Theme is not following the WordPress Codex.
It is clear that a WordPress template File has to be name with a certain unique (and very well defined) name, and put in a defined Folder Structure, to work.

If the Theme does not follow those standards, we can not guess where the Templates are and therefore the Layout Plugin would throw that error as no template is found with the call to layouts.

Have you tried the steps suggested?
Can you, despite the error, use Layouts Plugin?

I do not think I can help with this theme, it does not follow the WordPress Structure as outlined here:
https://codex.wordpress.org/Theme_Development
https://developer.wordpress.org/themes/basics/template-hierarchy/

But I can try to.
For this I need a valid copy of the Theme including the instrcutions where and how to find the templates.

You can use DropBox or google Drive to sahre it with me

Please aknowledge that I can only be of limited assistance on this, our Support Policy does not allow me to debug 3rd party Software.

#413776

I am downloading and analizing the theme.

For Avada we do have a integegration, please use it:
https://toolset.com/documentation/user-guides/toolset-avada-integration/

#413782

I made some tests and it has to be integrated into the native templates, such as index.php or page.php on the WordPress Hierarchy Folder.

I was able to use a Toolset Layout by adding this to index.php and respective page.php:

if ( defined( 'WPDDL_VERSION' ) && is_ddlayout_assigned() ) : // if Layouts Plugin is active and a layout is assigned

        the_ddlayout( );

    else: // if not use the normal WP loop
x_get_view( x_get_stack(), 'wp', 'page' ); 
endif;?>

As you see we do NOT call the Theme's header at any place, because the Theme tries otherwise to force his own header and footer to the site.

You can workaround this by creating a Layout "header" and then in the theme's filed header.php you call the_ddlayout( 'header' );

This will allow you to also style the header with Layouts.
Same for the Footer.

Or you just style the entire Template from header to footer with one Layout.

I am sorry to say that since this Theme does not follow WordPress common structure and coding standards as many other themes, integrating Layouts requires a bit more work than usual

#416519

Hi Beda, I ended up figuring an easy workaround for the X Theme - it's not to use Layouts at all and to use Views instead. Works like a charm. 🙂

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