Documentation / Elements / Post and Comments Lists

Overview

Github: Lists and Comments code

My thinking in the beginning that lists and comments share similar functions so I should have one function that handles both. I plan on splitting them up into two different PHP classes in the future since they are different and it will simplify handling them each separately. But here is the documentation for it for now.


Plugin Core Default Lists:

Duzz Custom Portal has a few built in list modes that don’t need any coding skills necessary:

  1. List All Projects
  2. List All Archived Projects
  3. List All Messages (Comments)
  4. Status Feed (List All Comments for a Project)
  5. Funds (List Payments/Invoices for a Project)

Custom Lists with PHP:

It is possible to create custom lists if you are comfortable with PHP. But you do risk breaking your site. So only attempt this with a test site first.


Table List

If you want to list any kind of entity like a Project or a custom post type, you will need to define which data you want to display for each column in the table. The only way to do that right now is creating a select2 menu on the WordPress backend to pick the metadata you want selected. You can find more information on how to do that here.

Now you will want to create a shortcode to create that table to list your posts with the data. Add this to your functions.php file:

PHP

function duzz_table_shortcode() {
    // Make sure Duzz plugin is active
    if (!class_exists('\Duzz\Shared\Layout\Pages\Duzz_List_Factory')) {
        return '';
    }

    $table_factory = new \Duzz\Shared\Layout\Pages\Duzz_List_Factory("demo_form", "project", "table", 10, "demo_demo_form_field_data", "selected_columns_demo");
    $container = $table_factory->duzz_create_list();

    return $container;
}

add_shortcode('duzz_table', 'DuzzAddon\duzz_table_shortcode');

You can limit the data displayed/listed with arguments too. Say you only want to display archived posts. You can add this code snippet like this: $table_factory->add_list_args(null, 'archive', 1); to your shortcode function like this:

PHP

function duzz_table_shortcode() {
    // Make sure Duzz plugin is active
    if (!class_exists('\Duzz\Shared\Layout\Pages\Duzz_List_Factory')) {
        return '';
    }

    $table_factory = new \Duzz\Shared\Layout\Pages\Duzz_List_Factory("demo_form", "project", "table", 10, "demo_demo_form_field_data", "selected_columns_demo");
    $table_factory->add_list_args(null, 'archive', 1);
    $container = $table_factory->duzz_create_list();

    return $container;
}

add_shortcode('duzz_table', 'DuzzAddon\duzz_table_shortcode');

You will notice that the Duzz_List_Factory class takes six arguments like this: Duzz_List_Factory([list name], [post type], [list type (table or comments)], [number of items to list], [options name], [list data]). You need your options name to create any table. Your options name is create by your select2 creator. You can read more about that here.