自定义 SilverStripe 中的导航菜单

发布于 2024-07-26 12:49:29 字数 1044 浏览 9 评论 0原文

我在 SilverStripe 论坛上问过这个问题,但一天都没有听到。 http://silverstripe.org/customising-the-cms/show/263604# post263604

我正在将基于 PHP 的静态网站 + Wordpress 迁移到 SilverStripe。

在静态页面中,我们自定义标题本身。 我们有两种类型的登录。 客户和附属公司。

在今天的静态网站中,我们做了这样的事情:

<? 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"); ?> 

这是联属网络营销和客户部分之间导航菜单的唯一区别。

我尝试走不同的布局路径。 但我不喜欢它,因为除了这个之外,布局看起来 99% 都是一样的。

我尝试了以下 hack,它有效,但我一点也不喜欢它。

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

关于如何更优雅地实现这一目标或更好推荐的实现方式有什么建议吗?

维克拉姆

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

趁年轻赶紧闹 2024-08-02 12:49:31

我不明白你所做的有什么问题......
其他解决方法是:

  • 为 SiteTree 页面对象添加“类型”属性,以便区分客户和联营公司。
  • 在 SiteTree 对象的控制器内部,您可以使用接收数组或对象的“customize”函数,并通过调用控制器内部也可用的“renderWith”函数来使用模板文件(.SS文件)。 这样,您的客户和联营公司的布局将被分隔在不同的 .SS 文件中。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文