2

When I add a Channel Entry with a title such as John's Test Entry, when EE outputs it to the template, it is outputting it as John’s Test Entry.

Notice the difference in the apostrophe? I've tried editing the entry - even in the database - to use a 'regular' apostrophe, but it always outputs like this.

I would like to disable this functionality in EE, as it is causing some internal PHP issues with some templates we are using. Is this possible?

Thanks!

1
  • Can you describe the PHP issues you are having and which fieldtype you are using?
    – foamcow
    Oct 7, 2014 at 10:50

3 Answers 3

1

It's not going to help you specifically, but titles are put through a typography filter you have no control over. Maybe use the query module to access title data when generating your entries, that should bypass the filter because it's direct from the db.

I had the same issue in reverse. Client wanted proper typography but WYGWAM would strip them and they didn't want to lose the functionality WYGWAM gave them.

Had to add a core hack to WYGWAM ultimately.

0

The only thing it might do is encode the ' character into an entity - which is actually rather desirable behaviour in order to prevent issues outputting content.

Are you feeding the offending text to the PHP to be parsed in some way? i.e. it's expecting the ' character but getting the character entity instead?

If you are able to edit the PHP templates then you could do a str_replace on the entity being created to turn it back into a '

0

As Steven vsaid, the Typography library in CodeIgnitor is whats transforming it to a curly quote. See the file /system/codeigniter/system/libraries/Typography.php, line 270 of the function format_characters.

You have 3 options :

  1. Just enter the quote encoded in your title

Simple really, instead of typing John's Test Entry type John's Test Entry, this works a treat if you can manage having pre-encoded characters in your titles, when they are displayed in the CP they are displayed correctly anyway, its just editing the entry.

  1. Use a string replace plugin or PHP on template to transform it

You can use a plug in like String Replace Exp, note that this will transform all right curly quotes, so if you are using legit opening closing single quotes you'll ruin these!

{exp:strrexp pattern="’" replace="'" string="{title}"}

Or turn PHP on (set to Output) and use (str_replace)[http://php.net/str_replace] itself like this :

<?php echo str_replace("&#8217;","&#39;","{title}"); ?>
  1. Hack the Core not recommended

If your confident enougth go to work in the Typography.php file to suit your needs.

Edit : And finally...

In a rare expidition into accuracy, to answer the exact OP question... To disable the functionality (for titles only) you will need to hack the core [NOT RECOMMENDED]. To do this you'll need to open up /system/expressionengine/modules/channel/mod.channel.php goto line 4551 and patch as so :

-   $title = ee()->typography->format_characters($query->row('title'));
+   $title = $query->row('title');

Please be sure to add some other validation code though! although this is done at the display stage we still don't want anyone smuggling some unsafe text through via the Entry title!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.