Jump to:

3447 Posts in 1032 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Controlling different pagetypes possible?

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

Page: 1
Go to End
Author Topic: 510 Views
  • dompie
    Avatar
    Community Member
    88 Posts

    Controlling different pagetypes possible? Link to this post

    Last week I tried to access a function from different PageTypes inside one FolderPage (see http://silverstripe.org/general-questions/show/14811). In the end I found a workaround, but went into this problem again today. Although I was sure, this should be no problem in Silverstripe, it turns out to be somehow impossible (I believe).

    My page hierarchy is as follows:
    FolderPage
    |-> DefaultPage
    |-> Page
    My class hierarchy:
    Page
    |-> DefaultPage
    |-> FolderPage

    In FolderPage I'd like to control all teaserable child pages of a FolderPage:

          <% if Children %>
          <% control Children %>
          <% if Teaserable %>
          <% if Last %>
          <div class="article last">
          <% else %>
          <div class="article">
          <% end_if %>
             $MyFirstImage
             <h2><a href="$Link">$Title</a></h2>
             $ShortText
          </div>
          <% end_if %>
          <% end_control %>
          <% end_if %>


    Although $MyFirstImage exists in DefaultPage_Controller, it's not callable from Template and I can't think of any workaround for this.
    Making MyFirstImage static is no solution due to required object scope (for DefaultPage.ss output). Putting MyFirstImage to DefaultPage would be almost an exact copy of the function already present in the controller (I hate that).

    From FolderPage.ss I can only call functions on DefaultPage not from DefaultPage_Controller. Is there any other way I could somehow load the DefaultPage_Controller inside FolderPage_Controller or call functions of DefaultPage_Controller from FolderPage.ss? I hope this is somehow understandable.

    510 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.