Jump to content

Force UTF-8 encoding for PW


jukooz
 Share

Recommended Posts

Hello,

I have pretty strange situation. Hosting that I'm working on is forcing ISO-8859-2 encoding. I don't have any real access to it, just ftp to folder where I'm installing a site. None of htaccess solutions worked - have no idea why. The only thing that worked for me was adding

header("Content-Type: text/html;charset=UTF-8");

to every template. But ProcessWire backend is still encoded in ISO-8859-2 and messy.

How to write module that would add it to every ProcessWire pageload? Or to which PW file and where I need to paste it (probably it will never be updated)?

My php skills are really poor. Know only basics that allow me to ingrate processwire to site.

Link to comment
Share on other sites

As a quick fix, you could add it to the top of /wire/templates-admin/default.php.

If you want to write a module for doing that, a simple autoload module which hooks right before Page::render and just sends the header there should be enough. The Helloworld.module that ships with ProcessWire default theme is a nice starting point for this (it's already autoload and demonstrates how hooks are used.) The only code you'll need in init() would look pretty much like this:

$this->addHookBefore('Page::render', $this, "sendHeader");

And your sendHeader() method would only need to contain that header you've posted above:

public function sendHeader() {
   header("Content-Type: text/html;charset=UTF-8");
}

Hope this helps!

  • Like 2
Link to comment
Share on other sites

Great thanks. I figured out changing default.php few minutes ago. It's working for me now.

Tried to make this module but I'm getting errors. They are about some classes but it doesn't matter. I have solution to my problem.

And since I use Teflon theme, Even PW update wouldn't break it :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...