Jump to content

Displaying tables of items in an application

Recommended Posts

I'm fairly new to IPS and I don't have a terribly firm grasp of the API yet so here are a few questions that hopefully boil down to something fundamental.

I need to implement functionality that works similarly to classified ads. It works like this: Users can enter data sets with title, content and a bunch of metadata. Visitors can look at a list of these data sets (showing a subset of the entered data) and click on each entry to get to a detail page.

The data sets are easy enough to implement; they're just an \IPS\Content\Item implementation. After that, though, it gets more complicated. The documentation seems to imply that a node controller would be the way to go; however, it also seems to imply that node controllers are always bound to a database table, which represents a list of nodes (like forums). While I could do that I'm not sure whether it's appropriate to add a table containing a single row that carries no actual meaning – after all, I only have the one group of items to show.

So is a table-backed node controller the way to go or am I overlooking something?

Also, I came across this news post describing a helper class for database-backed tables. This guide also mentions "PHP classes to build tables, lists etc". However, I was unable to find any class with "Table" in its name anywhere in IPS. Has IPSHelpersTableDb been dropped/never been shipped?   If so, is there another class that handles table generation or some other convenience functionality to kep me from having to reinvent the wheel?

Link to comment
Share on other sites

If you're using Content Items, the class you want to look at is \IPS\Helpers\Table\Content, but this is primarily for the front end. The simplest implementation of this is:

$table = new \IPS\Helpers\Table\Content( 'IPS\myapp\myclass', \IPS\Http\Url::internal( "app=myapp&module=mymodule&controller=mycontroller" ) );
\IPS\Output::i()->output = (string)$table;

That will generate a table for your content items using all the default options. After you see how that works you can start playing around with all the different options inside the class.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...