Broken ListView in custom module

I’m getting a popup error when I lick on “ListView” of a custom module in Studio. The title of the modal error window is: “An error has occurred” and the content is:

{“center”:{“title”:“ListView”,“crumb”:"|X|""</a> |X|""</a> | Studio</a> > Job Management System</a> > Layouts</a> > ListView</span>

“,“content”:”
\n\n

which also contains 2 broken image icons at “|X|” (this being my insertion and not part of the error output).

Any ideas?

OK, solved… I had written extra code into the listviewdefs.php file which broke the output.

Which begs another question… how would I include a javascript file on list view?

you can modify files in custom/modules/your_module

best regards

if you edit (or create if it doesn’t exist) a file at custom/modules/YOURMODULE/views/view.list.php

anything you echo in the method preDisplay will be included near the start of the page so you can add javascript to the page this way. If you’re adding a new preDisplay method it’s worth remember you should probably still call the parent method like this parent::preDisplay() so all the default code runs.

1 Like

Thanks for this - yes, I discovered that shortly after my post. I think it may be prudent for anyone else who needs to create such a file, that it should be in the following format:


<?php
/**
 * @file
 * custom/modules/[YOUR_MODULE_NAME]/views/view.list.php
 */
require_once('include/MVC/View/views/view.list.php');

class [YOUR_MODULE_NAME]ViewList extends ViewList {

    public function __construct()
    {
        parent::ViewList();
    }

    function preDisplay() {

        // Must have this otherwise it errors.
        parent::preDisplay();

    }

    function display() {

        // Must have this otherwise it errors.
        parent::display();

    }
}