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.

Template Questions /

Template for code in sub directory


Reply


2 Posts   629 Views

Avatar
nedmas

Community Member, 2 Posts

8 September 2011 at 4:32am

Hi,

I'm trying to organise my mysite/code folder by placing my code in sub directories, however when I do this SS defaults to using the Page.ss template.

For example I have the following file:
mysite/code/CaseStudies/ListPage.php

Which contains the class:
CaseStudies_ListPage

And I've tried putting the template in the following:
theme/ListPage.ss
theme/CaseStudies_ListPage.ss
theme/CaseStudiesListPage.ss
theme/CaseStudies/ListPage.ss
theme/Layout/CaseStudies_ListPage.ss
theme/Layout/CaseStudiesListPage.ss
theme/Layout/CaseStudies/ListPage.ss

None of which work. Can this be done or am I attempting the imposible?

Avatar
Willr

Forum Moderator, 5513 Posts

9 September 2011 at 1:32pm

The location of a class and the template location are quite disjoint. Actually class paths in general in SS are usually redundant since the autoloader loads all of the classes for you.

What is likely causing the issue here is your class name. SS uses an _ in templates to denote an action - i.e ClassName_Action.ss. So when it comes time to pick your CaseStudies_ListPage it may think ListPage is the action, not part of the CaseStudies.

I suggest using CaseStudiesListPage as your class name since convention would state that, or you may be able to explicitly define a template file on your class

static $template = 'CaseStudies_ListPage';