ETP Content Types
ETP Documentation :ETP Content Types
Standard page attributes
The content repository data model (a standard part of OpenACS 4) primarily keeps track of content items , each of which may have multiple content revisions . Thecontent_revision
object type refers to a row in the
cr_revisions
table. Each revision contains the
standard attributes of the pages you create with ETP, such as
Title, Description, and Content. Additionally, the standard
acs_object
attributes are stored for each revision,
such as the creation date and creating user.
Referring back to the definition of the default ETP application,
you'll notice that it specifies that the
etp_page_revision
content type is to be used for the
index page and for all content pages. etp_page_revision is a
subtype of content_revision, but does not add any additional
attributes. It is just for easier integration with the search
package. The page templates used by the default application may
refer to only the standard page attributes stored in the
cr_revisions
table.
Extended page attributes: why do we need them?
The standard page attributes, while providing all the basic functionality for a collaboratively edited website, are rarely sufficient to implement real world designs.Imagine you're creating an online scientific journal. The graphic design mockup shows you that each issue of the journal contains a table of contents listing all the articles in that issue. However, the table of contents is organized into multiple sections: Editorial, Research, Corrections, and so on. You also notice that the design assumes that each journal issue has a distinguishable publication date, and that each journal article has a distinguishable abstract (a quick summary of the writers' findings which can be skimmed or searched).
All the standard page attributes (Title, Description, Content, etc.) are still useful, but in order to provide the structured data elements implied by the journal templates, we need to define some extended page attributes. In particular, we know that journal issues need to have a publication date, and journal articles need to have a section and an abstract.
Defining a new content type
Creating a new content type is done by calling the
etp::define_content_type
procedure from one of your tcl library files. Here's how you
would accomplish the journal example discussed above:
The first 3 parameters toetp::define_content_type journal_issue "Journal Issue" "Journal Issues" { { publication_date "Publication Date" "Publication Dates" string "size=60" "" } } etp::define_content_type journal_article "Journal Article" "Journal Articles" { { section Section Sections string "" "" } { abstract Abstract Abstracts string "rows=24 cols=80" "" } }
define_content_type
are the
internal name of the content type, the name to display, and the
plural form of that name. The fourth parameter is a list of records
describing each extended page attribute. Each record is a list
containing the following values (in sequence):
- attribute_name
- pretty_name
- pretty_plural
- datatype (must be one of the entries in acs_datatypes: string, boolean, number, integer, date, etc.)
- html (a string containing html attributes for the input control. useful attributes are "size=X" to specify the size of standard input controls, and "rows=X cols=X" to specify the size of a textarea. Textareas will be used only if the datatype is string and html specifies rows or cols.)
- default_value (can either be a string denoting a single default value, or the name of a callback function you've defined in the etp namespace which is used to provide values for select lists).
etp::define_application
procedure to set
up a new application. To continue with our journal example,
you'd want to do this as follows:
Creating the templates that make use of your custom content types is the subject of the next page . After that's been done, the authors of the journal will be able to create a new issue of the journal simply by creating a new instance of the ETP package (a process that's automated within the ETP interface by the "create subtopic" command) and ensuring that the new content section is using the journal application. This setup can be automated, since it's possible to specify the application to use for any subtopic created within a particular directory.etp::define_application journal { index_template www/templates/journal-issue index_object_name "Journal Issue" index_content_type journal_issue content_template www/templates/journal-article content_object_name "Article" content_content_type journal_article }
luke@museatech.net |