WordPress.org

Ready to get started?Download WordPress

Forums

Cleverness To-Do List
Displaying only completed items (3 posts)

  1. hardcore253
    Member
    Posted 1 year ago #

    Hello again,

    I've got one other quick question regarding the 'completed' shortcode parameter for [todolist]:

    I was wanting to display a list of just the completed items, so I used the following shortcode

    [todolist title="Completed Tasks" completed="show"]

    My completed tasks are showing, but only underneath a list of uncompleted tasks. Is it possible to only show completed tasks?

    http://wordpress.org/extend/plugins/cleverness-to-do-list/

  2. Cindy
    Member
    Plugin Author

    Posted 1 year ago #

    No, not currently. I do have that on my feature request list though.

  3. hardcore253
    Member
    Posted 1 year ago #

    Firstly, thank you again for the response and glad to hear it is on the feature list for next update!

    Second - I actually figured out a way to get it to work - albeit a bit dirty.

    I opened the file: cleverness-to-do-list-frontend.class.php

    and found the section where the todolist shortcode parameters are read, and then the loop called to find all the items. Then I modified the code to look like this

    /** @var $category mixed */
    		if ( $category == 'all' ) $category = '0';
    		list( $this->url, $this->action ) = CTDL_Lib::set_variables();
    
    				/** @var $completed string */
    		if ( $completed == 'show' ) {
    
    					wp_reset_postdata();
    
    					if ( $type == 'table' ) {
    
    						$this->list .= '<table id="todo-list-completed" class="todo-table">';
    						/** @var $completed_title string */
    						if ( $completed_title != '' ) $this->list .= '<caption>'.$completed_title.'</caption>';
    						$this->show_table_headings( 1 );
    						$this->loop_through_todos( 1, $category );
    						$this->list .= '</table>';
    
    					} elseif ( $type == 'list' ) {
    
    						/** @var $completed_title string */
    						if ( $completed_title != '') {
    							$this->list .= '<h3 class="todo-title">'.esc_html( $completed_title ).'</h3>';
    						}
    						$this->list .= '<'.$list_type.' class="todolist">';
    						$this->loop_through_todos( 1, $category );
    						$this->list .= '</'.$list_type.'>';
    
    					}
    
    		}
    		/** @var $type string */
    		elseif ( $type == 'table' ) {
    
    			$this->list .= '<table id="todo-list" class="todo-table">';
    			/** @var $title string */
    			if ( $title != '' ) $this->list .= '<caption>'.$title.'</caption>';
    			$this->show_table_headings();
    			$this->loop_through_todos( 0, $category );
    			$this->list .= '</table>';
    
    		} elseif ( $type == 'list' ) {
    
    			/** @var $title string */
    			if ( $title != '') {
    				$this->list .= '<h3 class="todo-title">'.esc_html( $title ).'</h3>';
    			}
    			/** @var $list_type string */
    			$this->list .= '<'.$list_type.' class="todolist">';
    			$this->loop_through_todos( 0, $category );
    			$this->list .= '</'.$list_type.'>';
    
    		}
    
    		/** @var $completed string */

    So if the completed parameter is set to "show" it will only ever show completed items, otherwise, it will show all outstanding items. Like I said, dirty, but it gets the job done for how I'll be using it until you update.

    Not sure how you plan to implement a feature like this, but I know some folks will want to show ALL to-do's separated by uncomplete and completed as it currently works, and some will only want to show one or just the other - so maybe add one more parameter with a 0,1,2 value to drive if all items shown (0), just uncompleted (1) and just completed (2)?

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.