Hey guys, probably a pretty simple one! (if you’re wondering about all the naming, this one is for a stand up comedy website).
I’m using SS v4 and have set up the Class Comedian with data inputs and a ModelAdmin extension ManageComedians to add/edit them in the CMS. All that is working. But I can’t get the whole list of Comedians I’ve added to show on the page ComedianHolder.ss using $ViewComics. The controller can’t access the Comedians class. I’m getting the error: [Emergency] Uncaught Error: Class ‘SilverStripe\WellingtonComedy\Comedians’ not found
The following 3 pages are located in app/src:
Comedian.php:
use SilverStripe\ORM\DataObject;
use SilverStripe\Assets\Image;
use SilverStripe\AssetAdmin\Forms\UploadField;
class Comedian extends DataObject
{
private static $db = [
'Name' => 'Varchar',
'Blurb' => 'Varchar',
'Profile' => 'Text'
];
private static $has_one = [
'Photo' => Image::class,
];
private static $owns = [
'Photo'
];
private static $searchable_fields = [
'Name'
];
}
ManageComedians.php
use SilverStripe\Admin\ModelAdmin;
class ManageComedians extends ModelAdmin
{
private static $managed_models = [
Comedian::class
];
private static $url_segment = 'manage-comedians';
private static $menu_title = 'Manage Comedians';
private static $menu_icon_class = 'font-icon-happy';
}
ComedianHolder.php
namespace SilverStripe\WellingtonComedy;
use Page;
use PageController;
class ComedianHolder extends Page
{
private static $has_many = [
'Comedians' => Comedian::class,
];
private static $owns = [
'Comedians'
];
}
class ComedianHolderController extends PageController
{
public function ViewComics()
{
return Comedians::get()
->limit(6);
}
}
If it helps here’s the project on Github
Thanks heaps