RenderWith & Namespace

SS4.2

Question:

If I extend a Page Controller in a module, for example SilverShop/Page/CheckoutPageController , in the extension php file, i have

public function checkoutMethod(){
  $this->owner->renderwith('CheckoutPage_checkoutMethod'); 
}

But where shall i put the CheckoutPaeg_checkoutMethod.ss file? If i put it themes/mythemes/templates/Layout/CheckoutPage_checkoutMethod.ss it can’t be found.

I also put it under
themes/mythemes/template/SilverShop/Page/Layout/ but no luck.

finally, i already follow the controller_action.ss naming convention, do i need to run the renderwith method, can i just do

return array()

like SS3.0?

I had a similar problem with this (with the Sitemap2 module), albeit just overriding the existing template.

In my case, the correct location was

themes/{MYTHEME}/TractorCow/Sitemap2/Layout

However, the thing that got me was that I copied the folder structure from the Vendor folder, which turned out to be slightly different to the Namespace used in the Sitemap2 files.

So:
themes/{MYTHEME}/Tractorcow/Sitemap2/Layout

didn’t work but:
themes/{MYTHEME}/TractorCow/Sitemap2/Layout

did.

Also, I assume it is a typo in the post but in your description you said CheckoutPaeg_checkoutMethod.ss which surely should be CheckoutPage_checkoutMethod.ss?

@Phillbex

The typo was not the problem. the problem is SSviewer can’t find the CheckoutPage_checkoutMethod.ss file.

It can only find it if i put it under themes/mytheme/templates/CheckoutPage_checkoutMethod.ss

But SSViewer will render it without the themes/mytheme/templates/Page.ss and thus the page becomes headless

return array(), still works. The template goes into the same folder as your CheckoutPage.ss. i am not shure if this allready helps.

In which namespace is your app.
Eg CompanyPage => Namespace app

I have my page models in an folder that is called Pages
eg HomePage => Name HomepageModel

So my templates will be in themes/themename/templates/CompanyPage/Pages/Layout/HomePage.

From what i understood actualy you can overwrite the template with out an extension. Just look where the silvershop has its templates. eg if i wanted to overwrite a template from elemental
10

It would be:
themes/themename/DNADesign/Elemental/Layout/ElementHolder

if you want to use renderWith you have to combind it with customise()->renderWith() than it will be rendered with page.

I think Greg_808 has has answered it but this is the cut down version I’ve just used:

SS3:
return $this->customise($Data)->renderWith(array(‘MyTemplate’, ‘Page’));
== /templates/Layout/MyTemplate.ss

SS4.2.2:
return $this->customise($Data)->renderWith([‘Name/Space/MyTemplate’, ‘Page’]);
== /app/templates/Name/Space/Layout/MyTemplate.ss

The extra ‘Page’ in my array is a fall back incase the first template isn’t found. It can come out. It is optional.