是否有一种方法,是bla bla,就像在Subtext CMS(在asp.net btw上)那里被称为术语扩展或(关键字扩展)我不记得正确..对于Zotonic cms来替换一些定义的文本零件到链接?我的意思是: - 动物 - >应该替换为animal
啊,请帮助我..我将感激不尽。
答案 0 :(得分:0)
您可以使用自定义过滤器执行此操作。这是我用于邮件列表的一个简单示例,它将#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])).