Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » include SS files in Layout SS files?

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1
Go to End
Author Topic: 1666 Views
  • Aaron
    Avatar
    Community Member
    63 Posts

    include SS files in Layout SS files? Link to this post

    Quick question:

    Should you be able to include and render an ss file from the theme /include directory from within an ss file located in the them /layout directory? Or can you only do this from within an ss file in the theme root?
    e.g.
    1. /Layout/Tour.ss has <% include TourGallery %> in the code
    2. I have a file with HTML in it in /Includes/TourGallery.ss
    I can't get it to render.
    I think that maybe I need to have Tour.ss in the root beside Page.ss and HomePage.ss
    Cheers
    Aaron

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: include SS files in Layout SS files? Link to this post

    No you should have all your includes in the includes folder and then where ever you need be able to do <% include SuperCoolNewContent %> you can do. From inside a layout template or a root level template.

    See the default theme - it includes the sidebar this way.

  • Aaron
    Avatar
    Community Member
    63 Posts

    Re: include SS files in Layout SS files? Link to this post

    That seems to be what I'm doing though.
    The formatting of the linespaces in these forums makes this sort of explaination a bit hard, but here is what I have:

    1. Page.ss for my general pages
    2. Layout/Tour.ss for Tours pages (same as Page apart from a few layouts)
    3. Includes/TourGallery.ss - Rather long HTML code for a image gallery

    In Layout/Tour.ss, I have <% include TourGallery %> in a certain place. It does not render, but the way I understand your post it should??

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: include SS files in Layout SS files? Link to this post

    Yep that looks pretty right to me. Make sure its not something stupid like different filenames, make sure you flush etc etc

  • Aaron
    Avatar
    Community Member
    63 Posts

    Re: include SS files in Layout SS files? Link to this post

    Thanks Will,

    I found the problem to be an unclosed control in /Includes/TourGallery.ss. There was no error thrown like if you do the same in a Layout or Root template. It just didn't appear.

    All good now. Cheers for the confirmation.

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: include SS files in Layout SS files? Link to this post

    Good to hear, Im surprised it didnt throw any error. The parser is meant to be pretty strict on that sort of thing and throw a error. I might see if it happens for me, might be a issue with includes.

  • Aaron
    Avatar
    Community Member
    63 Posts

    Re: include SS files in Layout SS files? Link to this post

    I can try to replicate and post code if it helps

    1666 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.