How to use phplist functions in custom plugin pages?


I searched this forum, read the documentation ( and inspected some existing plugins. However, it’s still not clear to me how I can use phplist functions within a plugin page.
I use phplist version 3.3.1.

My goal:
I want to render a dropdown with all categories and then a list of all lists.

What I did:
Created MyPlugin.php and MyPlugin folder in a custom plugins folder.
Inside MyPlugin folder I have a page myindex.php.

Now I’m stuck. How can I get the data from the database in the page myindex.php?

In the documentation it says, that “PHPlist provides a variety of specialized functions for getting data from and storing data in the database, so that you may not need to access the database directly.” e.g. getListsAsArray()

But how do I call this function in myindex.php?

The file also provides methods for accessing the database directly and I set $database_module in config.php. The documentation says, “You can consider the database to be connected and there’s no need to connect again.”

But again, how to I use those methods? Do I have to include specific files? Add functions to the MyPlugin.php and access them in the myindex.php? Or pass data to the page? How?

I hope someone can show me the right way…


@lisa phplist will include your index.php file after it has included all of its own files. So you should be able to call any phplist function, as whichever file it is in should already have been loaded.

Look at admin/index.php where you can see the set of files that phplist includes.

Thanks for your fast response, Duncan!

Somehow I got it to break my page before, but now I’m calling the functions directly and it works.
Having a look at admin/index.php helped as well.