None of the following templates could be found

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

1 Like

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

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ā€¦!!

1 Like

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.

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.

Hi Kimk,

Page is working or getting server error?

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)?

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!

Did you work this out? I have the same issue that my includes such as Header.ss donā€™t work in my namespace Includes folder but do work in the templates/Includes folder. My HomePage.ss template works just fine in the namespace folder.
I find the documentation really confusing and everyone has a different idea of the best method.

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.

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:

1 Like

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

Totally helps to talk about things. I think this is the second time I have done this silly camel case mistake and read this and got this reminder. SideBar.ss vs Sidebar.ss - so easy to overlook, especially when everything is working on Wamp.

Thanks Kimk
Itā€™s wonderful that you posted your solution in the forum!
The same stupid mistake happened to me. Incorrectly typed CamelCase works perfectly on localhost, but not on Unix servers. (I tried my themes paths for two hours :frowning: )