2. Projects as pages of their own

In the previous tutorials, all records called up through the URL were located in the content area “Pages”. The “… housing” subpages did display content from the area “Projects”, but a single project could not be called up on its own. That is what we change first: Each project becomes a page of its own with its own URL.

Open the input fields of the content area “Projects”:

Press Ctrl + G (or ⌘ + G on a Mac); a search field appears. Type area:projects and press Enter.
Switch to the tab “Input fields”, click “Create” and, in the section “META FIELDS”, choose the type “Slug”.

Under “Position after...”, select the field “Title” and save.

Switch to the tab “Records”. The slugs are already visible in the list: camindo CMS created them from the default field of the area (the title).

The addresses of our projects should all start with “projects/”, e.g. “projects/birnbluetenweg-hamburg” or “projects/media-house-hamburg”. So that we do not have to put “projects/” in front of each slug individually, we define a “slug prefix” for the entire content area: Use the menu at the top right above the record list to switch to the Settings of the area, and click Edit.
In the field “Slug prefix”, enter the value projects and save. (camindo CMS adds the slash at the end automatically.)

Now we still need a page template that can be used to call up a single project:

Ctrl + G (or ⌘ + G on a Mac) > area:page_templates > “Create”

Name: page_project_details
Code:

(CMS:INCLUDE header)
<p>(CMS:TEXT online_at)</p>
<h1>(CMS:TEXT title)</h1>
(CMS:MEDIA image
  attr[style]="width:400px;height:auto;float:left;margin-right:20px;"
)
(CMS:TEXT text)
(CMS:SELECT list_see_also
  relation=ptr_see_also
  sort="_custom asc"
)
<br style="clear:both">
(CMS:INCLUDE footer)

Switch to the tab “Access”, select the area “Projects” under “Add content area”, tick “Default” and save. This makes the template the default template for all projects.

Next, we simplify the template that has listed the projects so far: Instead of the large image, it should only show a small preview image (thumbnail) without text. Thumbnail and title link to the new detail page. The “See also” list now appears on the detail page, so it is no longer needed here.

Replace the code of the template list_projects with:

(CMS:RESULT_START)
<hr style="margin:20px 0">
<a href="(CMS:URL)">
<p>(CMS:TEXT online_at)</p>
(CMS:MEDIA thumbnail
  attr[style]="width:200px;height:auto;float:left;margin-right:20px;"
)
<h2>(CMS:TEXT title)</h2>
</a>
<br style="clear:both">
(CMS:RESULT_END)

Click through the website and check that everything looks as expected:
On the “… housing” pages, the projects are now listed with only their date, title and a small image. Clicking a project opens its detail page with the large image and the text.