Forum Replies Created

Viewing 15 replies - 76 through 90 (of 124 total)
  • Thread Starter herold

    (@herold)

    @jack

    Thank you!

    Thread Starter herold

    (@herold)

    Hello Josh,

    Just send you an email with the patch.

    Thread Starter herold

    (@herold)

    Thanks Scott, I am working with these options already. I just wanted to have the title optimized the same way as the WordPress Posts and Pages, which gets customized by the SEO plugin.

    I am able to set parts of the title, but WordPress adds automatically the website name to the front. e.g sitename | my title

    Thread Starter herold

    (@herold)

    I will rework my stuff into CPT – just realized that ACT are left overs from version 1.0

    Thread Starter herold

    (@herold)

    Thanks Scott, at least I know now I am not doing anything wrong. As this manipulates the header stuff I guess there is no way of programing this myself?

    Thread Starter herold

    (@herold)

    Advanced Content Types stored in extra table.

    Thread Starter herold

    (@herold)

    ok, here is the updated code. I left some comments in it for testing purpose. Ready to be tested…

    <?php
    /**
     * @package Content Aware Sidebars
     * @author Joachim Jensen <[email protected]>
     */
    
    /**
     *
     * Pods Module
     *
     * Detects if current content is:
     * a) any or specific pods pages
     *
     */
    class CASModule_pods extends CASModule {
    
    	/**
    	 * Constructor
    	 */
    	public function __construct() {
    		parent::__construct();
    		$this->id = 'pods';
    		$this->name = __('Pods Pages',ContentAwareSidebars::DOMAIN);
    
    	}
    
    	/**
    	 * Get pods pages
    	 * @return array
    	 */
    	protected function _get_content() {
    
    		if ( function_exists( 'pods_api' ) ) {
    
        		// Get PodsAPI
        		$api = pods_api();
    
    		    // Get Pod Pages
        		$pod_pages = $api->load_pages();
    
    		    $pod_page_list = array();
    
    		    foreach ( $pod_pages as $pod_page ) {
            		$pod_page_list[$pod_page[ 'slug' ]] = $pod_page[ 'name' ];
        		}
    		}
    
    		return $pod_page_list;
    	}
    
    	/**
    	 * Determine if content is relevant
    	 * @return boolean
    	 */
    	public function is_content() {
    		return is_pod_page();
    	}
    
    	/**
    	 * Where query
    	 * @return string
    	 */
    	public function db_where() {
    
    		//$pods_name = pods_url_variable('first', uri);
    		//return "(pods.meta_value IS NULL OR pods.meta_value = '".$pods_name."')";
    		return is_pod_page($pod_page[ 'slug' ]);
    	}
    
    	/**
    	 * Meta box content
    	 * @global object $post
    	 * @return void
    	 */
    	public function meta_box_content() {
    		global $post;
    
    		echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
    		echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'. "\n";
    		$meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX . $this->id, false);
    		$current = $meta != '' ? $meta : array();
    
    		echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'. "\n";
    		foreach ($this->_get_content() as $id => $name) {
    			echo '<li><label><input type="checkbox" name="' . $this->id . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
    		}
    		echo '</ul>'. "\n";
    		echo '</div>'. "\n";
    	}
    
    }
    Thread Starter herold

    (@herold)

    @scott

    That information helps improving the where clause:

    public function db_where() {
       return is_pod_page($pod_page[ 'slug' ]);
    }
    Thread Starter herold

    (@herold)

    @scott

    Excellent!

    Thread Starter herold

    (@herold)

    Here is a better way to list the Pods Pages:

    foreach ( $pod_pages as $pod_page ) {
       $pod_page_list[$pod_page[ 'slug' ]] = $pod_page[ 'name' ];
    }

    This way we don’t need to filter the ‘/*’ signs, which I mentioned above.

    Thread Starter herold

    (@herold)

    It is for Pods Pages only as they were not working with a dynamic sidebar. Pods via theme templates work fine as they are recognized as WordPress pages.

    I had to dig into this because of SEO issues. If you use dynamic content from Pods via WordPress Theme you can’t have dynamic page titles set, because the title is set by the WordPress page.

    Thread Starter herold

    (@herold)

    Ok, I put another few hours of work in and I have a working version that can now select a sidebar depending on a specific pods page. However the code needs to be cleaned up.

    Here are the things that need to be better coded:
    – Name of pod is url – used (/*) filter ?
    – pods_url_variable(‘first’, uri) may not work is pod is ‘second’

    Here is the code:

    <?php
    /**
     * @package Content Aware Sidebars
     * @author Joachim Jensen <[email protected]>
     */
    
    /**
     *
     * Pods Module
     *
     * Detects if current content is:
     * a) any or specific pods pages
     *
     */
    class CASModule_pods extends CASModule {
    
    	/**
    	 * Constructor
    	 */
    	public function __construct() {
    		parent::__construct();
    		$this->id = 'pods';
    		$this->name = __('Pods Pages',ContentAwareSidebars::DOMAIN);
    
    	}
    
    	/**
    	 * Get pods pages
    	 * @return array
    	 */
    	protected function _get_content() {
    
    		if ( function_exists( 'pods_api' ) ) {
    
        		// Get PodsAPI
        		$api = pods_api();
    
    		    // Get Pod Pages
        		$pod_pages = $api->load_pages();
    
    		    $pod_page_list = array();
    
    		    foreach ( $pod_pages as $pod_page ) {
            		$pod_page_list[] = str_replace("/*", "", $pod_page[ 'name' ]);
        		}
    		}
    
    		return $pod_page_list;
    	}
    
    	/**
    	 * Determine if content is relevant
    	 * @return boolean
    	 */
    	public function is_content() {
    		return is_pod_page();
    	}
    
    	/**
    	 * Where query
    	 * @return string
    	 */
    	public function db_where() {
    		$pods_name = pods_url_variable('first', uri);
    		return "(pods.meta_value IS NULL OR pods.meta_value = '".$pods_name."')";
    
    	}
    
    	/**
    	 * Meta box content
    	 * @global object $post
    	 * @return void
    	 */
    	public function meta_box_content() {
    		global $post;
    
    		echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
    		echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'. "\n";
    		$meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX . $this->id, false);
    		$current = $meta != '' ? $meta : array();
    
    		echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'. "\n";
    		foreach ($this->_get_content() as $id => $name) {
    			echo '<li><label><input type="checkbox" name="' . $this->id . '[]" value="' . $name . '"' . (in_array($name, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
    		}
    		echo '</ul>'. "\n";
    		echo '</div>'. "\n";
    	}
    
    }
    Thread Starter herold

    (@herold)

    I have the pods plugin as far as it works for any pod page selected. This is pretty good so far. Maybe you can help adding the code to expand on selecting sidebars depending on a specific pod page.

    Here is the working code so far:

    <?php
    /**
     * @package Content Aware Sidebars
     * @author Joachim Jensen <[email protected]>
     */
    
    /**
     *
     * Pods Module
     *
     * Detects if current content is:
     * a) any or specific pods pages
     *
     */
    class CASModule_pods extends CASModule {
    
    	/**
    	 * Constructor
    	 */
    	public function __construct() {
    		parent::__construct();
    		$this->id = 'pods';
    		$this->name = __('Pods Pages',ContentAwareSidebars::DOMAIN);
    
    	}
    
    	/**
    	 * Get pods pages
    	 * @return array
    	 */
    	protected function _get_content() {
    
    		if ( function_exists( 'pods_api' ) ) {
    
        		// Get PodsAPI
        		$api = pods_api();
    
    		    // Get Pod Pages
        		$pod_pages = $api->load_pages();
    
    		    $pod_page_list = array();
    
    		    foreach ( $pod_pages as $pod_page ) {
            		$pod_page_list[] = $pod_page[ 'name' ];
        		}
    		}
    
    		return $pod_page_list;
    	}
    
    	/**
    	 * Determine if content is relevant
    	 * @return boolean
    	 */
    	public function is_content() {
    		return is_pod_page();
    	}
    
    	/**
    	 * Where query
    	 * @return string
    	 */
    	public function db_where() {
    		return true;
    
    	}
    
    	/**
    	 * Meta box content
    	 * @global object $post
    	 * @return void
    	 */
    	public function meta_box_content() {
    		global $post;
    
    		echo '<h4><a href="#">'.$this->name.'</a></h4>'."\n";
    		echo '<div class="cas-rule-content" id="cas-' . $this->id . '">'. "\n";
    		$meta = get_post_meta($post->ID, ContentAwareSidebars::PREFIX . $this->id, false);
    		$current = $meta != '' ? $meta : array();
    
    		echo '<ul id="cas-list-' . $this->id . '" class="cas-contentlist categorychecklist form-no-clear">'. "\n";
    		foreach ($this->_get_content() as $id => $name) {
    			echo '<li><label><input type="checkbox" name="' . $this->id . '[]" value="' . $id . '"' . (in_array($id, $current) ? ' checked="checked"' : '') . ' /> ' . $name . '</label></li>' . "\n";
    		}
    		echo '</ul>'. "\n";
    		echo '</div>'. "\n";
    	}
    
    }
    Thread Starter herold

    (@herold)

    In pods you can add code into a pre code form. Here you can define any variable that can be picked up before calling the sidebar. That could be used as an ID. for example:

    $pod_page_id = 5;

    The pods plugin for Content Aware Sidebars can read this variable and knows that it is a pod page.

    Thread Starter herold

    (@herold)

    Hello Scott,

    Thank you – not sure where this will go. I think I first have to work on the return array that lists the pod pages. It looks like it needs to be in a certain format. See below:

    /*
    		return array(
    				'Page 1'	=> __('Page 1', ContentAwareSidebars::DOMAIN),
    				'Page 2'	=> __('Page 2', ContentAwareSidebars::DOMAIN),
    				'Page 3'	=> __('Page 3', ContentAwareSidebars::DOMAIN)
    		);
    		*/
Viewing 15 replies - 76 through 90 (of 124 total)