views:

767

answers:

1

I asked this question in SilverStripe forum, but haven't heard in a day. http://silverstripe.org/customising-the-cms/show/263604#post263604

I am in the process of migrating a static PHP based site + Wordpress to SilverStripe.

In the static pages, we customize the header itself. We have two types of logins. Customers and Affiliates.

In the static site today, we do something like this:

<? require("_header_top.html"); ?> 
<? if (isset($display_affiliate_link) && $display_affiliate_link == true) { 
require("_header_middle_affiliate.html"); 
} else { 
require("_header_middle.html"); 
} ?> 
<? require("_header_bottom.html"); ?>

This is the only difference in the Navigation menu between the affiliate and customer sections.

I tried going down the different layout path. But I don't prefer it as the layouts look 99% the same except for this one.

I tried the following hack, which works, but I don't like it at all.

<% if MenuTitle = Affiliate %> 
<a href="/affiliate_login>affiliate login</a> 
<% end_if %> 
<a href="/subscriber_login>subscriber login</a>

Any suggestion on how I can achieve this more elegantly or a better recommended way to implement this?

Vikram

+1  A: 

I do not understand what is wrong with what you did... Other workarounds would be:

  • Add a "Type" property for your SiteTree page object, in order to separate between a customer and an affiliate.
  • Inside the SiteTree object's controller you can use the "customize" function which receives either an array or an object, and by calling the "renderWith" function which is also available inside the controller to render the array/object with a template file (.SS files). This way your layout for a customer and an affiliate will be separated in different .SS files.
StarScream