Types

One of the main qualities, the most important in fact, of Chameleon are types. The type system integrated into Chameleon allows for a great extensibility and customizability on the user's part, which means you can personalize your blog in ways not possible in other blogging engines. Simply installing or creating a new type allows you to easily extend your blog to something more personal, and more customized to your needs.

What are types?

Types are Chameleon's answer to an ever more occuring problem: more and more users want to post different sorts of content on their websites. When blogs first appeared, they were small personal diaries written by some technical users and experienced writers who wanted to get their opinion out there. Over the years however, blogging evolved into a complete different medium. This means not only the amount of offered content increased, but also the variety of the subjects, the variety of styles of blogs, and the variety of types of content published on them. Blogs are not "just" a personal online diary anymore, they've become complete websites.

To keep up with this evolution, blogging engines will have to change. A blogging engine should not only be able to publish texts; images, audio and video also have to be supported. This is what Chameleon does, it has a system to allow all these types of content to be published.

How do types work?

When you create a new entry in Chameleon, you can select its type, just like you would for example select its title or author. Corresponding to the type you select, different fields are displayed on the admin page. If you want to publish an image, you get an upload field. If you're writing a review, you get to give it a rating.

Depending on what type an entry is, it also gets displayed differently. If you publish a review, the page your visitors will get to see will include the rating you entered. If you publish a podcast, the page will include a download link.

These pages are all fully customizable. If you want your users to be able to listen to your podcast with a flash player embedded in your website, this is completely possible. If you want to show the rating of a review in a sidebar using stars, there's nothing preventing you from doing that. Every type gets an other template, so you can change the pages of each type to be completely different.

Installing a new type

Currently, it's not yet possible to install a new type using the admin center. You can copy and paste some files to install a type, but then don't forget to add the type to the database! In version 0.7, a system to manage the types will be introduced.

Creating a new type

Unfortunately, there isn’t any interface to manages types, this is expected to be added in version 0.7. Therefore, if you want to create a type, you will have to add the type record to the database table types manually. This won’t be hard, as you can follow the example of existing types.

The interface for the type in both front-end and back-end then, has to be created in the views. The file app/views/admin/entries/_type_<typename>.rhtml should contain the input fields for the type. You can create such a file by simply copying an existing one (the article one is a good one, since it only contains the two required fields and no metadata), and change it according to your type (using for example meta-fields, take a look at the review type template as an example). Please make sure you change the IDs accordingly, and don’t change the names of the description and contents fields!

For the display of your type on the front-end then, you need to create a file app/views/blog/_show_<typename>.rhtml. If you want to use a CSS stylesheet with it, you can create one at public/stylesheets/type_<typename>.css. Again, the article template may form a good reference, and the review template shows how to deal with metadata.

page_revision: 6, last_edited: 1173730069|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.