Jump to content


Photo
- - - - -

How to convert DMS to support Loopbuddy?

loopbuddy loop Pagelines

  • Please log in to reply
1 reply to this topic

#1 AmsBunDem

AmsBunDem

    Newbie

  • Members

  • 1 posts
  • LocationItaly
  • Framework Version:DMS 2.1.1
  • Country: Country Flag

Posted 14 July 2014 - 02:25 PM

LoopBuddy, by iThemes, is plugin that overwrites the WordPress Loop using a combination of custom queries and layouts and allows you to customize the content, post-by-post, category-by-category, all with a drag-and-drop interface without having to touch a single line of PHP code.

 

It's very interesting, but there is still a catch: A WordPress theme needs to support the Loop Standard in order to take full advantage of the flexibility of this plugin...
So a two-step process is needed to make Pagelines DMS compatible with LoopBuddy.

 

This two-step process consists of:

  1. Adding the necessary support for LoopBuddy into your active theme’s functions.php file
  2. Wrapping the theme’s current WordPress loop with a conditional statement.

No problem on STEP (1), it simply need to add support for the Loop Standard and two PHP functions that define what is happening with the dynamic_loop():

 
add_theme_support('loop-standard');

if ( ! function_exists( 'dynamic_loop' ) ) {
    function dynamic_loop() {
        global $dynamic_loop_handlers;
        if ( empty( $dynamic_loop_handlers ) || ! is_array( $dynamic_loop_handlers ) )
            return false;
        ksort( $dynamic_loop_handlers );
        foreach ( (array) $dynamic_loop_handlers as $handlers ) {
            foreach ( (array) $handlers as $function ) {
                if ( is_callable( $function ) && ( false != call_user_func( $function ) ) ) {
                    return true;
                }
            }
        }
        return false;
    }
}
if ( ! function_exists( 'register_dynamic_loop_handler' ) ) {
    function register_dynamic_loop_handler( $function, $priority = 10 ) {
        global $dynamic_loop_handlers;
        if ( ! is_numeric( $priority ) )
            $priority = 10;
        if ( ! isset( $dynamic_loop_handlers ) || ! is_array( $dynamic_loop_handlers ) )
            $dynamic_loop_handlers = array();
        if ( ! isset( $dynamic_loop_handlers[$priority] ) || ! is_array( $dynamic_loop_handlers[$priority] ) )
            $dynamic_loop_handlers[$priority] = array();
        $dynamic_loop_handlers[$priority][] = $function;
    }
}

The STEP (2) is more problematic, especially for someone who is NOT a developer, as in my case: it is to locate the WordPress loops in the theme and wrap the loop with a PHP conditional statement that asks whether or not we are using the dynamic_loop() function to override the original loop. The code looks like this:

 
<?php if (!dynamic_loop()) : ?>
    ORIGINAL LOOP
<?php endif; ?>

I suppose it's need to wrap multiple loops in different places. (single, page, archive, 404, etc), but I was not able to do... Is there anyone who can help me?

 

THANK YOU



#2 Danny

Danny

    Is Awesome!

  • Moderators
  • 16997 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 15 July 2014 - 10:59 AM

Hi,

 

Unfortunately, this isn't really something we can provide support for. However, I don't actually think it will be possible, as DMS uses sections to display the loop and not the standard WordPress method. You will probably want to speak to the developers of the plugin for assistance.







Also tagged with one or more of these keywords: loopbuddy, loop, Pagelines