Contents

Almost everything you create and display in Dubsite is called "Content", for example Articles, Menus, Loginforms, Listings or Webforms. Each content can be categorized (using terms from vocabularies), displayed in different ways (with displaytemplates), assigned to pages and blocks and be access-protected (with permissions).

Viewing content

Each content has it's own, unique URL, under which it can be displayed in the frontend. Another way to present content is by displaying it on a page or a block. This way you can arrange multiple contents below each other. A single content can be assigned to as many pages/blocks you want.

Content can only be viewed in the frontend, if 3 things are provided:

  1. The content's status must be "active". The default status of newly created content is "inactive". You can change the status when you create/edit content.
  2. The user calling that content must be authorized to view it (by default you don't have to worry about this).
  3. A displaytemplate must be assigned to the content (by default you don't have to worry about this).

Creating content

To create an article and display it on a certain page, do this:

  1. In the backend go to Site -> Contents and click "Create content...".
  2. Open the box "Display on pages and blocks" and select a page or a block, on which you want the article to be shown. Then select the contenttype "Article" and enter a name for the article. Finally click "Create".
  3. Type some text in the article and set the content's status from "inactive" to "active" in the selectbox on top.
  4. Save the article by clicking either the green "X" on top of the screen (to save and close) or the green checkmark (to just save).

An alternative way of creating/editing content is by using the "Onsite Editor", which lets you create and edit content directly in the frontend. This plugin is included and already installed in the default package.

Do not forget to set the status of newly created content from "inactive" to "active". Otherwise it will not be shown in the frontend!

Displaytemplates

To make the presentation of contents more flexible, each content uses a displaytemplate when it is rendered on the screen. Displaytemplates are templates for single contents. They determine, what data will be displayed (e.g. whether to show the intro-text of an article or not), and how it will be presented (HTML).

Dubsite comes with some default displaytemplates, that you can assign to contents. Here's how you change the displaytemplate of a content:

  1. In the backend go to Site -> Contents and click on the name of the desired content to edit it.
  2. Click the tab "Settings" on top, select a different displaytemplate and save the content.

If you now view the content in the frontend, you should see the difference, depending on the selected displaytemplate.

A displaytemplate is technically a view script for a Zend_View (just like the .phtml-file of a template). In a displaytemplate you can write PHP-code and access certain variables with the syntax $this->variable_name (see below). This way a displaytemplate can provide it's own programming-functionality, and since it's just PHP and no fancy CMS-scripting-language, it is easy for programmers to implement custom functionality. However, a displaytemplate should not contain hundreds of lines of PHP-code, because it would make more sense to write a new plugin, if more complex functionality is required.

Additionally to the standard Zend_View members the following variables are accessible in a Dubsite-displaytemplate:

  • $this->data: Array with contenttype-specific values. $this->data['intro'] for example contains the intro-text of an artricle (if the displaytemplate is for the contenttype "Article").

  • $this->content_id: ID of the displayed content.

You can edit displaytemplates in the backend under Site -> Displaytemplates.

The flexibility of displaytemplates is useful for example if you want to display a list of articles on one page, where each article is shown only as a short preview-version with a link to the full version of the article. Look at the displaytemplate "Article Preview" for the contenttype "Article", which does exactly that (in conjunction with the Listing-plugin). Keep on reading below to learn how to set up such a list with the "Listing"-contenttype.

Showing lists of contents

In case you have a big amount of articles (e.g. for a magazine), you need a comfortable way to present them to your visitors. It would not make sense to embed every single article in a page, which would be pretty static.

Instead, you should create a "Listing", which dynamically displays content in the frontend. By telling the listing to render the articles with a special preview-displaytemplate (which is included in the default Dubsite package), you get a list of article-previews, with links to the full version of each article. Above that, listings can be sorted in the desired way. Nice and easy!

A listing is just another contenttype, and you can create it on a page just like you would create an article. In the following example we use the "Onsite Editor" in the frontend to create a new listing (you could also do this in the backend under Site -> Contents):

  1. Make sure you're logged in and go to the page in the frontend, where you want the listing to be shown.
  2. Click the "plus"-sign on top of the page, then select "Listing" as contenttype, enter a name and click "Create".
  3. In the editing-interface, select "Article" as the contenttype to be listed.
  4. Select "Article Preview" as the displaytemplate, that will be used to render the articles.
  5. For now just ignore the other settings, set the listing from "inactive" to "active" (the selectbox on top) and click "Save and Back" (the green X on top).

When you're back on the page you should see a list of all existing articles, displayed as previews. Articles, that have an intro-text and/or a thumbnail will be displayed accordingly, otherwise you will just see the article's title.

You could also configure the listing to show contents based on categorization. Only contents, that have the selected terms associated to them, would then be displayed. This is useful e.g. for a list of News-Articles. You could create the term "News" in a vocabulary (under Site -> Vocabularies in the backend), then categorize your news-articles with this term and let the listing show only Articles, that are categorized as "News".

Rules

Sometimes it is useful to apply certain properties to newly created content, depending on the content's categorization. For example, if you have a News-section on your site (as described above), you may want to assign a special displaytemplate to News-Articles, that shows the creation-date and the author's username above the text. In this case rules can simplify your workflow considerably.

This example shows you how to create and apply a rule, that sets a special displaytemplate to new articles, if they are created in a certain category. It is assumed that you have a fresh Dubsite-installation, where the category "Computers" and the Listing of computers exist by default.

  1. Go to Configuration -> Rules in the backend and create a new rule with a name of your choice.
  2. Now you see the editing-interface of the rule. In the "Weight"-textfield enter "5" or any number below 10. This is necessary, because we want this rule to have a higher priority than the already existing default rules, which were created during installation (and which have a weight of "10").
  3. Select "Article" as the contenttype, to which this rule will be applied.
  4. Select "Apply rule, when new content gets created in a certain category".
  5. Select the category "Computers" (which exists in the default installation of Dubsite).
  6. Select "Assign a displaytemplate" as the action to be executed.
  7. Select the displaytemplate, that will be assigned to the content ("Article Full" may be a good choice, because it shows the date and the author's username above the text).
  8. Save the rule.

Each new content, that you now create with the category "Computers" will get the displaytemplate "Article Full" automatically:

  1. Go to Site -> Contents and click "Create content...".
  2. Select the contenttype "Article", give it a name of your choice and select the category "Computers" for it. Click "Create".
  3. Type some text in the article's body, set the article to "active" and save it.

Now go to the frontend (by clicking the "Home"-icon on top) and click on "Computers" in the menu. You will see your new article in the list. Click the title of the article to get to the detail-view. Now you should see your article with the "Article Full" displaytemplate (with date and username on top).

Rules are also useful if you want to set the URL-path of new content. For example, if you have the category "News" and you want all articles, that get created in this category, to sit below the URL "/news".

Access control

Each content can be protected with permissions, that restrict access to this Content. If a content is protected with multiple permissions, users must have at least one of these permissions to be allowed to view it.

To protect a content with permissions,

  1. go to Site -> Contents in the backend and click the name of the content (or the edit-icon on the right).
  2. Click the tab "Settings" on top.
  3. Add the desired permission(s) in the box "Access control".

Access to content is also controlled on the contenttype-level. Meaning: If a user has not the permission to view the contenttype "Article" at all, then he will never see an article, independent from the article's individual access restriction. You can administer permissions in the backend under Users -> Permissions.