0

Is there a method, yes bla bla, like in Subtext CMS (on asp.net btw) which is called there Terms Expansion or (Keyword Expansion) i don't remember correct.. For Zotonic cms to replace some defined text parts to links? I mean: -- animal -> should be replace to animal

Ah, please well help me.. I will be gratefull.

ComFreek
  • 29,044
  • 18
  • 104
  • 156
in4man
  • 23
  • 8
  • i saw some notification in documentation for regular expression replacements, but in that online demo i didn't find such thing. Does someone know, if it possible use it on all records (items, news, etc.). Thanks. – in4man Jun 09 '13 at 06:30
  • anyone? maybe tutorial? – in4man Jun 09 '13 at 08:21
  • like SEO Smart Links for WP. I am totally dont familar with Zotonic, but Liked it A Lot. So could anybody point out, what is the direction to move in? – in4man Jun 09 '13 at 08:32

1 Answers1

0

You could use a custom filter to do this. Here's a simple example I use for mailing lists which replaces #NAME with the name of the recipient:

-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])).
goibhniu
  • 110
  • 5