Support » Plugin: Dynamic Widgets » Pods support in dynamic widgets?

Viewing 11 replies - 1 through 11 (of 11 total)
  • To get all available Pod Pages when Pods is active:

    if ( function_exists( 'is_pod_page' ) ) { // Check to see if Pod Pages are activated
        $pod_pages = pods_api()->load_pages();
    
        foreach ( $pod_pages as $pod_page ) {
            // display $pod_page[ 'name' ]
            // id is $pod_page[ 'id' ]
        }
    }

    To get the name from an ID, you can use:

    if ( function_exists( 'is_pod_page' ) ) {
        $pod_page = pods_api()->load_page( array( 'id' => $id ) );
    
        if ( !empty( $pod_page ) )
            $pod_page_name = $pod_page[ 'name' ];
    }

    Then to detect whether or not to show the widget:

    if ( function_exists( 'is_pod_page' ) ) {
        if ( is_pod_page( $pod_page_name ) ) {
            // show widget
        }
    }

    I’m adding the ability to pass the ID to is_pod_page in Pods 2.0.5, due out later this week.

    Plugin Author Qurl

    (@qurl)

    You should see a Pods section somewhere at the bottom of the DW widget options. Is that available to you?

    Hi Qurl

    No I do not have a Pods section. I see the following sections:
    Role
    Date
    Days
    Weeks
    Browser
    Templates
    URL
    Posts Page
    Single Posts
    Attachments
    Pages
    Author pages
    Category Pages
    Tag Pages
    Archive Pages
    Error Page
    Search Page
    Picture tag archive

    I am using Dynamic Widgets v1.5.3, it has (FILTER) after the version on the widget options page, and I am using Pods v2.0.4.1

    Plugin Author Qurl

    (@qurl)

    Ok, I have to look into Pods v2.0.4.1. I think something has changed along the way in Pods which makes DW not detecting Pods anymore.

    I’ll check the DW code too to see if I can help you.

    Oh I see now, you did a custom SQL query instead of using the API. Use the API calls given in this thread instead and it should work with Pods 2.0

    For 1.x compatible code that works with 2.0, try this:

    if ( function_exists( 'is_pod_page' ) ) { // Check to see if Pod Pages are activated
        if ( function_exists( 'pods_api' ) )
            $pod_pages = pods_api()->load_pages();
        else
            $pod_pages = $GLOBALS[ 'wpdb' ]->get_results( "SELECT <code>id</code>, <code>uri</code> FROM <code>&quot; . $GLOBALS[ 'wpdb' ]->prefix . &quot;pod_pages</code>", ARRAY_A );
    
        foreach ( $pod_pages as $pod_page ) {
            // display $pod_page[ 'name' ], Pods 1.x uses $pod_page[ 'uri' ]
            // id is $pod_page[ 'id' ]
        }
    }
    if ( function_exists( 'is_pod_page' ) ) {
        if ( function_exists( 'pods_api' ) )
            $api = pods_api();
        else
            $api = new PodAPI();
    
        $pod_page = $api->load_page( array( 'id' => $id ) );
    
        if ( !empty( $pod_page ) ) {
            if ( function_exists( 'pods_api' ) )
                $pod_page_name = $pod_page[ 'name' ];
            else
                $pod_page_name = $pod_page[ 'uri' ];
        }
    }
    Plugin Author Qurl

    (@qurl)

    Hi Scott,

    DW checks for the existence of the constant PODS_VERSION_FULL. When that exists, it assumes Pods is available.

    Pods module is in ./mods/pods_module.php
    The worker (script that takes care of acting upon the rules) has a pods section starting at line 761

    Check for defined( ‘PODS_DIR’ ) instead.

    Plugin Author Qurl

    (@qurl)

    Ah, right Scott. Thanks for that!

    Plugin Author Qurl

    (@qurl)

    Following the advice from Scott -thank you very much!- I have implemented the code into Dynamic Widgets development version 1.5.3.2. Please note it’s not fully tested, but I assume Scott knows where he is talking about. 😉

    http://downloads.wordpress.org/plugin/dynamic-widgets.zip

    Code looks solid to me, good job!

    I haven’t actually tested it though, but you covered everything I’d thing would be necessary.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Pods support in dynamic widgets?’ is closed to new replies.