Quick Start Guide

Skip to end of metadata
Go to start of metadata

Introduction

In this Quick Start Guide we are going to create a basic contentpage.
This contentpage consists of a controller/action and a view.

First I recommend you to read the overview. This helps you to understand what we are doing here. Furthermore I recommend you to read the documents-page. This page explains you what we are doing here. Together with this Quick Start Guide you should be able to understand pimcore documents in general.

The first few steps will be done directly in the code. Only for the last steps we are logging into the backend.

Create a new controller/action

Create a new PHP file in the folder /website/controllers and name it to ContentController.php
Open the file an put the following content into it.

This is a basic setup of an action/controller. The method “enableLayout” registers Zend_Layout to decorate our contentpage. In the defaultAction we can put some custom code or assign values to the template.

<?php

class ContentController extends Pimcore_Controller_Action_Frontend {

    public function defaultAction () {                
        $this->enableLayout();
    }
}

Do not end the file with a "?>". This is not recommended by Zend. You will find in some documents here that this has been done, but I recommend against it.

Create the template

Now we can create the templates for our new contentpage.
Create a new folder in /website/view/scripts and name it like the controller (in this case “content”). Put a new PHP file into this folder and name it like our action (default.php).
Then we can put some template code into it, for example:

<?php $this->layout()->setLayout('standard'); ?>

<h1><?php echo $this->input("headline", array("width" => 540)); ?></h1>

<?php while ($this->block("contentblock")->loop()) { ?>
    <h2><?php echo $this->input("subline"); ?></h2>
    <?php echo $this->wysiwyg("content"); ?>
<?php } ?>

Add Layout

Pimcore uses the advantages of Zend_Layout out of the ZF, for details please read more here about it.

Because we have enabled the layout engine in our controller, we can use layouts to wrap our contentpage with another template which contains the main navigation, a sidebar, …

With this code:

 <?php $this->layout()->setLayout('standard'); ?>

We tell the engine that we want to use the layout standard. Now create a new php file in the folder /website/views/layouts and name it to standard.php (just like the name of the layout appending .php).

Then we can also put some HTML and template code into it:

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/static/source/css/screen.css" />
</head>

<body>
<?php echo $this->layout()->content ?>
</body>
</html>

The code <?php echo $this->layout()->content ?> is the placeholder where your contentpage will be inserted.

Adding the layout/template to a page

Now we need to connect the template to a page. This will now be done in the pimcore-backend.

First click on the left under "Documents" at "home" and then select the tab "settings" in the newly opened window. You will then see something like this:

In controller and action you will have to write the name of the controller and the name of the action. After you have saved it you can test this new controller and action.

Testing it

After clicking on the edit tab you should see something like this:

which will look like this (in the frontend) when its filled with content:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 30, 2010

    Raffael Luthiger says:

    Just a small note about the controller code. According to the ZF documentation y...

    Just a small note about the controller code. According to the ZF documentation you should never close the controller code with a "?>". Because if you have accidentally  an empty line afterwards then you already create some output.

  2. Dec 30, 2010

    Raffael Luthiger says:

    And another remark. For someone with a totally new installation of pimcore with...

    And another remark.

    For someone with a totally new installation of pimcore without any example data the chapter "Create the template" is a little bit too short. After creating the file /website/view/scripts/content/default.php how should I be able to see this "edit mode"? And with what URL should I see the content in the frontend? I tried with http://testserver/content/default but it didn't work.

    1. Jan 11, 2011

      Jeroen van Sluijs says:

      In preview-mode, press the globe-with-mousepointer icon to see the content in th...

      In preview-mode, press the globe-with-mousepointer icon to see the content in the front-end.

      1. Jan 11, 2011

        Raffael Luthiger says:

        Hi Jeroen, I made my comment at a time when this Quick Start Guide was differen...

        Hi Jeroen,

        I made my comment at a time when this Quick Start Guide was different. I got now the edit privileges and I changed a lot in this guide. The old version of this guide didn't say anything about the backend.

        If you have some comments about this guide, let me know. I try to enhance this guide.

        Raffael

  3. Jan 22, 2011

    koen Huybrechts says:

    Hi, I did exactly what is prescribed in the quick start guide, but I get this e...

    Hi,

    I did exactly what is prescribed in the quick start guide, but I get this error:

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller class ("ContentController")' in C:\xampp\htdocs\plandawebsite\webroot\pimcore\lib\Zend\Controller\Dispatcher\Standard.php on line 352

    Any idea why?

    1. Jan 22, 2011

      Raffael Luthiger says:

      Does the file /website/controllers/ContentController.php maybe not have the righ...

      Does the file /website/controllers/ContentController.php maybe not have the right permissions?

  4. Feb 07, 2011

    Michael Ender says:

    A screen shot of how the 'settings' screen should look would be great.  I a...

    A screen shot of how the 'settings' screen should look would be great.  I am getting an error as well, and i'm guessing I probably don't have it set up correctly.

    1. Feb 07, 2011

      Raffael Luthiger says:

      I am still waiting to get the permissions to upload pictures. I have the screens...

      I am still waiting to get the permissions to upload pictures. I have the screenshot already here on my computer. I hope that I get it soon.

    2. Feb 09, 2011

      Raffael Luthiger says:

      I added now the screenshot. Please test it. Do you still get the error message a...

      I added now the screenshot. Please test it. Do you still get the error message afterwards?

  5. Jun 01, 2011

    Sandeep Narwal says:

    I made content controller and show action and views, but it give below error: U...

    I made content controller and show action and views, but it give below error:

    Uncaught exception 'Zend_Controller_Router_Exception' with message 'No route, document, custom route or redirect is matching the request: /content/show
    How to fix it? Also Html editor is coming on textarea in all latest browser on my Mac.

    Thanks

    1. Jun 01, 2011

      Raffael Luthiger says:

      The routes are not working as in a normal zend framework application. In the bac...

      The routes are not working as in a normal zend framework application. In the backend you have to create new web pages and there you have to add the controller/actions as the chapter "Adding the layout/template to a page" shows you. You can then navigate to the url of this web page.