7 January 2014 at 11:29am
(Last edited: 7 January 2014 11:30am),
I have built a module that replaces all email addresses on the website with a link to a contact form for spam protection.
In SS2.4 and 3 I used to do the replacement in the forTemplate() method of the DBField classes (Varchar, Text, HTMLVarchar, HTMLText). This way all emails shown on the website were replaced and I was still able to use $Field.RAW where the email address had to stay.
Now in SS3.1 the RAW doesn't work anymore, meaning that the email addresses still get re-written.
Does anyone have an idea why RAW does behave this way in SS3.1?
Can anyone give me a hint where to do the rewrite other than the forTemplate() method of the DBField classes? Is there a way to somehow inject something like a rewrite_hash_links or something similar to shortcodes?
17 January 2014 at 11:41am
Thanks for your reply.
Unfortunately this is not the solution I'm after. First you would need to call the parser in the templates for every field, second it would only work for Text/HTMLText fields and not for Varchar/HTMLVarchar.
What I had before SS3.1 was a solution where EVERY email address anywhere on the website was replaced (apart from hard coded ones in the templates).
I agree that this is probably because of the default casting. But it is still strange that RAW results in the value being converted to xml anyway. But that's probably because the surrounding template is converted to xml by the default casting later on. Is there a way to prevent this from happening in order to get the RAW to be really RAW?
Or maybe there is a way to change the behavior not of the db fields but the template parsing?
Thank you very much.