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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Extend Page.ss on module


Go to End


3 Posts   1500 Views

Avatar
webs86

Community Member, 1 Post

14 February 2015 at 3:36am

Edited: 14/02/2015 3:37am

Hello,
I'm developing my first module silverstripe. The structure of my form is:

 

 code /
---- ModulePage.php
---- ModuleItem.php
templates /
---- Layout /
-------- ModulePage.ss
-------- ModuleItem.ss
_config.php 

The file ModuleItem.ss is used for the following custom action:

     public function show ()
     {
         if ($ this-> urlParams ['ID'] && is_numeric ($ this-> urlParams ['ID'])) {
             return $ this-> renderWith ('PortfolioItem', array (
                 'PortfolioItem' => DataObject :: get_by_id ("PortfolioItem", $ this-> urlParams ['ID'])
             ));
         }
         return false;
     }

My problem is that you see the basic layout without the menu etc ... In Page.ss file of the theme is the variable $ Layout. The result is only processing the file ModuleItem.ss.

Where am I wrong?

Thanks for the help

Avatar
zenmonkey

Community Member, 545 Posts

18 March 2015 at 3:40am

I assume ModuleItem is DataObject not a page. You need to use the Template_function.ss pattern in naming your files.
ModulePage.ss
ModulePage_show.ss (instead of ModuleItem.ss)

Look at DataObjectsAsPage module as a guide. Search results are rendered the same way. Page_results.ss renders the Results functions

Avatar
wmk

Community Member, 87 Posts

18 March 2015 at 5:07am

Hi,

congratulations for the first module!

you either need a _config.php or a _config dir with yml configuration file in it that silverstripe assumes a folder to be a module. I'd go for the _config/ dir with yml, but the _config.php is good for the beginning, see docs

DataObjectAsPages guide is a bit outdated, did you see the new lessons on doc.silverstripe.org? And as zenmonkey states correctly: try to rename the template...