Confused about Content Rewriter

Creating and modifying plugins.
Post Reply
VeinoM

Confused about Content Rewriter

Post by VeinoM »

So I'm confused how to use content rewriter... I don't understand the example given for the "Rewrite String"

Say everytime I have the word "test" always changed to "testing, one two" or something like that... (i don't want this, just a hypothetical situation) what would I put in each of the fields?

Thanks.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Confused about Content Rewriter

Post by garvinhicking »

Rewrite String: "{to}"
Rewrite Char: ""
New Title ({from}): "test"
New Description ({to}): "testing, one two"

So you can see, the "Rewrite String" can make use of {to} and {from} variables. The "New Title" value allows you to enter what is the source of your rewrite ({from}, "test"). The "New Description" value is the {to} variable and says what your wording shall be rewritten to ("testing, one two").

So you use the Rewrite String usually to add any special HTML markup using {from} and {to}.

Now, everytime Serendipity finds your word "test" it will save the word 'test' in the temporary variable {from}. It will then look up in which word it shall be transfered to and saves that in the variable {to}. Then it will look up your Rewrite String and replace "test" with the parsed contents of the Rewrint String. As this is set to "{to}" only, the {from} variable will completely vanish.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lauterunfug
Regular
Posts: 54
Joined: Wed Mar 16, 2005 9:26 am

Post by lauterunfug »

I made manually a new blog entry with the word 'test' in the text.
Then I went to the RewritePlugin and tried what you wrote:
Rewrite String: "{to}"
Rewrite Char: ""
New Title ({from}): "test"
New Description ({to}): "testing, one two"
But nothing happens. And I tried to use {ziel} instead of {to} because my blog is in german. But this does not work too...

What am I doing wrong???
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

The rewriter has problems if the words you want to translate are in between word boundaries. Try to enter "test test test test" into your blog entry?

It might also be that if you've enabled the entryproperties cache, that this is interfering?

Plus, you should try to avoid using the same {from} value in youer {to} string. So instead of "testing, one two" better use "experiment, one two" ;)

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lauterunfug
Regular
Posts: 54
Joined: Wed Mar 16, 2005 9:26 am

Post by lauterunfug »

thanks for that. seems that it works now. but not 100%...
will do further experiments...
cu
tom
mbirth
Posts: 4
Joined: Sun Feb 19, 2006 10:12 am
Location: DE, Berlin
Contact:

Post by mbirth »

Garvin, is it possible to change the plugin so that you don't have to add each search/replace-pair manually but enter them all into one big textarea?

Idea behind this: I migrated from MovableType and there I had this nice acronym-plugin which read all entries from a textfile. The textfile looked like this:

Code: Select all

FTP:File Transfer Protocol
FYI:For Your Information
GAU:Größter Anzunehmender Unfall (worst case scenario)
GB:Gigabyte (1 GB = 1024 MB)
GBA:Nintendo Gameboy Advance
GCC:GNU Compiler Collection
GCN:Nintendo GameCube
Maybe you could use another separator so that the versatility isn't harmed.

Cheers,
-mARKUS

P.S.: I'd do it myself, but since I don't have access to your SVN, it would be complicated to integrate the changes into the final S9Y. Also it's your plugin so I thought I might ask you first. ;-)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

It would be possible, yes. I would suggest adding a textarea as an alternative of entering the values.

The SVN is accessible publically, so you can get the latest sources easily and then create a patch file against SVN so that I can include your patch. I'd very much appreciate this, so have a go! :-)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply