Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Customising the CMS /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

[SOLVED] Error creating a new page type


Go to End


3 Posts   1144 Views

Avatar
madmaurice

Community Member, 20 Posts

10 February 2010 at 5:00am

Edited: 10/02/2010 8:40am

I create a homepage for a fire department.
They want to publish some information about there vehicles.
I created a new module folder named fwmodule.
fwmodule/code/VehiclePage.php:

<?

class VehiclePage extends Page {
    static $db = array(
        'Fahrgestell'=>'Varchar(100)',
        'Motorleistung'=>'Varchar(100)',
        'Aufbau'=>'Varchar(100)',
        'Baujahr'=>'Varchar(20)',
        'Funkrufname'=>'Varchar(50)',
        'Besatzung'=>'Varchar(100)',
        'Ausruestung'=>'Text',
        'Einsatzbereich'=>'Text'
    );
    
    static $has_one = array(
        'Bild'=>'Image'
    );
}

class VehicleController extends Page_Controller {
    public function init() {
        parent::init();
    }
}

?>

fwmodule/templates/VehiclePage.ss:

<h1 class="title">Fahrzeug (Details)</h1>

<div class="vehicledetails">
<div class="photo">$Bild</div>
<div class="details">
    <table>
        <tr><td class="left">Fahrgestell</td><td class="right">$Fahrgestell</td></tr>
        <tr><td class="left">Motorleistung</td><td class="right">$Motorleistung</td></tr>
        <tr><td class="left">Aufbau</td><td class="right">$Aufbau</td></tr>
        <tr><td class="left">Baujahr</td><td class="right">$Baujahr</td></tr>
        <tr><td class="left">Funkrufname</td><td class="right">$Funkrufname</td></tr>
        <tr><td class="left">Besatzung</td><td class="right">$Besatzung</td></tr>
    </table>
</div>
</div>
<h2>Ausr&uuml;stung (besonders)</h2>
<p>
    $Ausruestung
</p>
<h2>Einsatzbereich</h2>
<p>
    $Einsatzbereich
</p>

and an empty fwmodule/_config.php

sry for the names of the variables, im from germany^^

the page type is shown in the backend and can be created but when i open the page i get nothing but the class name of the pagetype

not even the design around it...

Attached Files
Avatar
Hamish

Community Member, 712 Posts

10 February 2010 at 7:27am

Your page controller must be called VehiclePage_Controller.

Also, I don't think you want the template in the /templates/ folder - you want it in the /templates/Layout folder so that it wraps your VehicalPage content in the normal page template.

Also, it is good practise to use full <?php tags instead of <?

Neither of these really explain the error though, but fix them up and see if it helps.

Avatar
madmaurice

Community Member, 20 Posts

10 February 2010 at 8:40am

Works. I think this was because of the Layout folder cause i already tried VehiclePage_Controller in an earlier version but forgot to copy it when switching to a newer version of ss...