有没有一种方法,是的,bla bla,就像在 Subtext CMS(在 asp.net btw 上)中被称为术语扩展或(关键字扩展)我不记得正确.. 对于 Zotonic cms 将一些定义的文本部分替换为链接? 我的意思是:--动物-> 应该替换为动物
啊,请帮帮我.. 我将不胜感激。
您可以使用自定义过滤器来执行此操作。这是我用于邮件列表的一个简单示例,它将#NAME 替换为收件人的姓名:
-module(filter_inject_firstname).
-export([inject_firstname/3]).
-include("zotonic.hrl").
inject_firstname(Body, undefined, _Context) ->
Body;
inject_firstname(Body, Recipient, _Context) ->
Val = case proplists:get_value(props, Recipient, []) of
Props when is_list(Props) ->
[{email, proplists:get_value(email, Recipient)},
{name_first, proplists:get_value(name_first, Props)},
{name_surname, proplists:get_value(name_surname, Props)},
{name_surname_prefix, proplists:get_value(name_surname_prefix, Props)}];
_ ->
[{email, proplists:get_value(email, Recipient)}]
end,
Name = proplists:get_value(name_first, Val),
iolist_to_binary(re:replace(Body, "#NAME", Name, [global])).