How to create some kind of administration page in a block?

Permalink
Hi all,

I'm new to concrete5 and I'm currently working on my first block. It is a bookshelf block that shows a list of books (with associated properties) from the database.

From what I gather is that the add.php file can contain a form needed to initialize the block (e.g. set certain options for a block). While this is most convenient I need something else.

By use of the XML file I have created a table to hold the book information. This information in turn will be used to generate the output.

What I fail to understand is how I can create some administration page where I can list the current books in the database and allow users to add/delete/update information to the database. I would appreciate if someone could point me to the right direction.

Thanks

 
jordanlev replied on at Permalink Reply
jordanlev
So what you want to do is let users manage the books from a dashboard page, but not in the block add/edit dialog itself (the block would just display the books that were entered in the dashboard). Is this correct?

If so, you'll want to make a package, not just a block. The package would contain its own db.xml file for the books table, and it would also contain the dashboard pages (the "view" of a dashboard page would be in YOURPACKAGE/single_pages/dashboard/bookshelf.php, and the "controller" would be in YOURPACKAGE/controllers/dashboard/bookshelf.php).

Your package would also contain the block that displays the books. But the add/edit portions of the block are not really necessary (unless you wanted someone to be able to choose certain books to display or filter certain categories or something like that). You still need to have add.php and edit.php, but they can basically just be blank (maybe put a little message in there like "no configuration options available for this block").

Note that even though your block isn't saving any data itself, you still need to have a db.xml file for it that defines a table, and the table MUST have 2 fields -- a "bID" integer field, and at least one other field. The "bID" field is so the system can keep track of which block is on which page, and the other field is just to prevent an error that will come up due to a bug in the core system. I just call this other field "dummy" to make it clear that it doesn't hold data but instead just exists to resolve this system bug.

For more info on creating dashboard pages, this is an excellent walkthrough (although note that this tutorial is focused on displaying the data as a "single page", not as a block like you want to do):
http://www.concrete5.org/documentation/how-tos/developers/build-a-s...

And if you want to see how to make a block with no fields, you could use the Designer Content addon and generate a block with just some "Static HTML" to serve as an example for all of the required files for the block:
http://concrete5.org/marketplace/addons/designer-content...

Good luck!

-Jordan