Dataobject template not loading

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Silverstripe 4.4.4

I have setup my Silverstripe 4 and am slowly updating a clients website from 3 to 4 which is a bit of a ball ache as it is quite different and I am not used to 4.

I have setup a dataobject page using the RegionsPage.php lessons number 9 so I can make sure it is correct. Everything is working backend. Problem I have is that the template is not showing. See code below. The main page.ss is showing but the testimonialspage.ss in Layout is not showing with all the data and I can’t for the life of me work out what is what. Any help would be very helpful.

Steve

==============

Testimonial.php

<?php

namespace SilverStripe\Lessons;

use SilverStripe\ORM\DataObject;
use SilverStripe\Assets\Image;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\AssetAdmin\Forms\UploadField;
use SilverStripe\Versioned\Versioned;

class Testimonial extends DataObject {
 
  // Testimonial object's fields
  private static $db = [
    'Name' => 'Varchar(255)',
    'Description' => 'Text',
	  'Content' => 'Text',
    'Affiliation' => 'Varchar(255)',
	  'SortOrder' => 'Int',
  ];
 
  // One-to-one relationship with profile picture and Testimonial list page
  private static $has_one = [
    'ProfilePicture' => Image::class,
    'TestimonialsPage' => TestimonialsPage::class,
  ];
  
  // Summary fields
  private static $summary_fields = [
    'Name' => 'Name',
    'Description' => 'Description',
    'Affiliation' => 'Affiliation',
	'Content' => 'Content',
  ];

	    private static $owns = [
        'ProfilePicture',
    ];
	
	private static $table_name = 'Testimonial';
	
	private static $extensions = [
        Versioned::class,
    ];  
	private static $default_sort = ['SortOrder ASC'];
	private static $versioned_gridfield_extensions = true;
	
	 public function getCMSFields()
    {
        $fields = FieldList::create(
            TextField::create('Name'),
            TextareaField::create('Description'),
			TextareaField::create('Content'),
			TextField::create('Affiliation'),
            $uploader = UploadField::create('ProfilePicture')
        );

        $uploader->setFolderName('testimonial-photos');
        $uploader->getValidator()->setAllowedExtensions(['png','gif','jpeg','jpg']);

        return $fields;
    }
}

================

TestimonialsPage.php

<?php

namespace SilverStripe\Lessons;

use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use Page;

class TestimonialsPage extends Page {
 
  // One to many relationship with Testimonial object
  private static $has_many = [
    'Testimonials' => Testimonial::class,
	  ];
	
private static $owns = [
        'Testimonials',
    ]; 
	
	public function getCMSFields()
    {
		
		// $config = GridFieldConfig_RecordEditor::create();
    	// $config->addComponent(new GridFieldOrderableRows('SortOrder'));
        $fields = parent::getCMSFields();
        $fields->addFieldToTab('Root.Testimonials', GridField::create(
            'Testimonials',
            'Testimonial list:',
            $this->Testimonials(),
            // $config
			GridFieldConfig_RecordEditor::create()
        ));

        return $fields;
    }
}


=================
TestimonialsPageController.php

<?php
namespace SilverStripe\Lessons;
use PageController;
class TestimonialsPageController extends PageController
{
}

Your Page and Controller are both in the namespace SilverStripe\Lessons, so you need to make your template directory structure match that as well.

You’ll want it at: themes/skilltec/templates/SilverStripe/Lessons/Layout/TestimonialsPage.ss

(I think !)

As an aside, it’s best not to use ‘SilverStripe’ as your top-level namespace. Generally speaking it should be something specific to the application or the vendor creating the code, to help reduce the chances of namespace collisions and autoloading problems down the line.

Thanks for your help

Okay I have changed the namespace and added the appropriate folder hierarchy to the themes folder but get this when flushing the front end not the template or page.ss parent.

15

Okay so what I did is to start again and add my own vendor folder and add my extensions and templates there which I suppose how it should work. I then added namespaces to these elements of the path and it seemed to find them. I assume there was something not right with the namespace paths I was using.

Did you change the page type in the CMS and re-publish the page?