None of the following templates could be found

templates
Tags: #<Tag:0x00007f10cc7d4a90>

#1

Silverstripe Version: 4.2.1

Where exactly do I have to put my template files in order for them to get found?

There are some contradictory information out there and it seems there is no up-to-date documentation. I have to say that this is my first attempt using Version 4.2.1. I had an attempt with 4.0, but then had no time and now in version 4.2.1 everything seems to work differently again. The entire folder structure changed and I got lost.
Sorry, about this, but it is really frustrating when you spend one day to find out how to get your custom theme recognised and now I have difficulties to get my template getting found…

Apologies for my long description here, but now that my templates don’t work, I am not convinced that I really got this right with the theme…

What I have done regarding my theme:
This is my current folder structure:
app
_config
app.yml
theme.yml:

Name: mytheme

SilverStripe\View\SSViewer:
themes:
- ‘$public’
- ‘SS4’
- ‘$default’
SilverStripe\i18n\i18n:
default_locale: ‘en_GB’

src
HomePage.php
HomePageController.php
SlideShowPhoto.php
templates
Includes
Layout
mynamespace
Includes
SlideShow.ss
Layout
HomePage.ss (include SlideShow)
Page.ss

public
assets
resources
themes
SS4
css (Symbolic link)
fonts (Symbolic link)
images (Symbolic link)
js (Symbolic link)
vendor
themes
SS4
css
fonts
images
js
composer.json (as described in some other forum entry:
“type”: " silverstripe-recipe",
“extra”: {
“expose”: [
“css”,
“js”,
“images”,
“fonts”
]
}
vendor

I did the dev/build, but I got the error message “None of the following templates could be found”. Btw. it all worked fine in SS3.6.

I tried to add the templates folder to the themes folder as in SS3.6 and entered text, so that I could make out which HomePage got recognised, but it was definitely not the one from the themes folder.

What do I have to do to get my templates recognised?

Any help is really very much appreciated!

Kind regards,
Kim


#2

I am having the same issue. Can’t find the way to accomplish this also.
I hope some body can guide us with an Answer.

I will keep checking, to see if I can find the solution.

I found this, not sure if this will help: https://docs.silverstripe.org/en/4/developer_guides/templates/template_inheritance/

Template Inheritance

Theme types

Templates in SilverStripe are bundled into one of two groups:

  • Default Templates, such as those provided in mymodule/templates folder.
  • Theme templates, such as those provided in themes/mytheme/templates folders.

The default templates provide basic HTML formatting for elements such as Forms, Email, or RSS Feeds, and provide a generic base for web content to be built on.

Template types and locations

Typically all templates within one of the above locations will be nested in a folder deterministically through the fully qualified namespace of the underlying class, and an optional type specifier to segment template types. Basic template types include Layout and Includes , and a less commonly used Content type.

For instance, a class SilverStripe\Blog\BlogPage will have a default template of type Layout in the folder vendor/silverstripe/blog/templates/SilverStripe/Blog/Layout/BlogPage.ss .

Note: The optional type , if specified, will require a nested folder at the end of the parent namespace ( SilverStripe\Blog ) to the class, but before the filename ( BlogPage ).

Templates not backed by any class can exist in any location, but must always be referred to in code by the full path (from the templates folder onwards).

Nested Layouts through $Layout type

SilverStripe has basic support for nested layouts through a fixed template variable named $Layout . It’s used for storing top level template information separate to individual page layouts.

When $Layout is found within a root template file (one in templates ), SilverStripe will attempt to fetch a child template from the templates/<namespace>/Layout/<class>.ss path, where <namespace> and <class> represent the class being rendered. It will do a full sweep of your modules, core and custom code as it would if it was looking for a new root template, as well as looking down the class hierarchy until it finds a template.

This is better illustrated with an example. Take for instance our website that has two page types Page and HomePage .

Our site looks mostly the same across both templates with just the main content in the middle changing. The header, footer and navigation will remain the same and we don’t want to replicate this work across more than one spot. The $Layout function allows us to define the child template area which can be overridden.

app/templates/Page.ss

<html>
<head>
    ..
</head>

<body>
    <% include Header %>
    <% include Navigation %>

    $Layout

    <% include Footer %>
</body>

app/templates/Layout/Page.ss

<p>You are on a $Title page</p>

$Content

app/templates/Layout/HomePage.ss

<h1>This is the homepage!</h1>

<blink>Hi!</blink>

If your classes have a namespace, the Layout folder will be found inside of the appropriate namespaced folder.

For example, the layout template for SilverStripe\Control\Controller will be found at templates/SilverStripe/Control/Layout/Controller.ss .

Jose Ortiz
mejor epoca para viajar


#3

Hey @Kimk,

The SilverStripe version 4 has directory structure be like this,

All model and controller file like HomePage.php and HomePageController.php put into app/src folder you can follow the screenshot.

then in the themes folder, you can create your theme suppose mytheme,

then in theme.yml file, you have to put your theme name like this follow the screenshot.

Screenshot%20from%202018-12-17%2010-10-31

And in your theme folder (mytheme) you can add all css, js and ss files and you can add your custom templates files in mytheme/templates/Layout.

Lastly, do the flush your site using your-domain/dev/build?flush=all.

Hope this helps you…:slightly_smiling_face:

Thanks…!!


#8

It’s Work For me.

After rebuilding through /dev/build/flush=all, the same errors was there. And When I Reload : http://localhost/folder, It’s OK.


#4

Hi addwebsolution,

Thank you for your quick relpy.
So, I followed your instructions and

  • deleted the templates folder from the app folder

  • and inserted it in the themes folder.

The theme already existed in theme.yml.

  • I did **your-domain/dev/build?flush=all

  • As I still had the ‘public’ in the theme.yml, I deleted this and did the dev/build?flush=all again,

but in both cases I ended up landing on the default ‘Home’-page - not the expected content and styling.

Comparing it with the simple theme, it is now set-up like this, but still doesn’t work…

What am I missing here?

Thanks.


#6

Hi Kim,

SS4 requires templates to be in fully namespaced locations that match your page classes, so for example, if your HomePage class is actually App\Model\HomePage then the Template needs to be in the following directory structure:

themes
 SS4
  templates
   App
    Model
     Layout
      HomePage.ss

That might be why templates are not found? If not, then could you post the full error you get (including any stack traces)?


#5

Hi Kimk,

Page is working or getting server error?


#7

Hi PsychoMo,

Thank you for your answer. After all this try and error I completely forgot about the namespace folder.
The namespaced location templates*app\namespace* didn’t work. I got the default content for the Homepage, not my Homepage specific content.

When I put my Includes and Layout in the following directory structure:

themes
 SS4
  templates
    Includes
      Navigation.ss  (etc.)
    Layout
      Page.ss
    mynamespace
     Includes
       SlideShow.ss
     Layout
       HomePage.ss
    Page.ss

then I get the error message (title of this question) regarding the SlideShow: None of the following templates could be found: Array ( [0] => Array ( [type] => Includes [0] => SlideShow ) [1] => SlideShow ) in themes "Array ( [0] => $public [1] => SS4 [2] => $default ) "
SSViewer.php:215

When I move the SlideShow to the templates/Includes folder, I get the HomePage with the content I expect.

Does that mean that I don’t need the Includes folder under mynamespace folder?

Thank you very much for the right hint, PsychoMo!


#9

Sorry, guys, I have to come back to this one…

This time only the Breadcrumbs are missing… although it is there and all the other files in the include folder work perfectly fine.

I upgraded to 4.3.3 and on my local (WAMP) everything works perfectly fine, but when I uploaded it to the host server I get the error above. The thing is, I uploaded another project recently which works perfectly fine. I developed it in the same way.
Can it be that one file is missing in SilverStripe (I FTP-uploaded, but that hasn’t been an issue with the other project)?
Not the ’ Breadcrumbs’ in the template which is the only I get the error message for. All other files in the include folder work fine.

Has anybody any idea?

Thank you very much.


#10

Sometime it helps when you speak about things…

In this case it was simple. I had a typo in my <% include Breadcrumbs %> and the file name is BreadCrumbs.
That doesn’t explain why it is working on my WAMP (it seems to ignnore camelCase), but just in case somebody else has a similar stupid error, I post my error here :wink:


#11

Ignoring case may well be a Windows thing - Linux and other OS’s are a little more particular about case-sensitivity