2009年10月22日星期四

Re: [fw-mvc] Encoding

Problem solved! Your answer saved my work!
Thanks a lot!


2009/10/22 Hector Virgen <djvirgen@gmail.com>
No I pasted it on pastie:

http://pastie.org/665529

--
Hector



On Thu, Oct 22, 2009 at 2:17 PM, Andre Fernandes <fernandes.andre@gmail.com> wrote:
Ok, I will try that, thanks a lot.

I am sorry for doing a Reply only, I will not do that again.

And the class meta.php I could not see, was an attachment?

Thanks again.



2009/10/22 Hector Virgen <djvirgen@gmail.com>
Sorry, it should look like this:

resources.meta.httpEquiv.Content-Type = "text/html; charset=UTF-8"

Also, you need to add this line to the top of your application.ini to load custom bootstrap resources:

pluginPaths.Default_Resource = APPLICATION_PATH "/resources"

Place the class I sent you in the file application/resources/Meta.php.

I hope that helps!

BTW don't forget to click "reply to all" when responding to messages in this mailing list :)

--
Hector



On Thu, Oct 22, 2009 at 1:29 PM, Andre Fernandes <fernandes.andre@gmail.com> wrote:

I have tried with the following lines and I have had no problem for the hyphen. But no meta setted too... :-(

resources.view.meta.httpEquiv.Content-Type = "text/html; charset=UTF-8"
resources.view.meta.meta.httpEquiv.Content-Type = "text/html; charset=UTF-8"

When I have tried with the following line, there was an exception:


resources.meta.meta.httpEquiv.Content-Type = "text/html; charset=UTF-8"

Exception:
Fatal error: Uncaught exception 'Zend_Application_Bootstrap_Exception' with message 'Unable to resolve plugin "meta"; no corresponding plugin with that name'




2009/10/22 Hector Virgen <djvirgen@gmail.com>
Setting the view's encoding does not automatically create a meta tag.

I've created a simple "meta" bootstrap resource that lets you define your default meta tags in application.ini.


Using that class you can update your application.ini with a line like this:

resources.meta.meta.httpEquiv.Content-Type: "text/html; charset=UTF-8"

Let me know if that works.. not sure if application.ini can accept hyphens in the key name (Content-Type)

--
Hector



On Thu, Oct 22, 2009 at 11:42 AM, Andre Fernandes <fernandes.andre@gmail.com> wrote:
The HTML generated is the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
<head>
<title></title> <link href="/css/global.css" media="screen" rel="stylesheet" type="text/css" /></head>
<body>
<style>
a:link,
a:visited
{
color: #0398CA;
}

span#zf-name
{
color: #91BE3F;
}

div#welcome
{
color: #FFFFFF;
background-image: url(http://framework.zend.com/images/bkg_header.jpg);
width: 600px;
height: 400px;
border: 2px solid #444444;
overflow: hidden;
text-align: center;
}

div#more-information
{
background-image: url(http://framework.zend.com/images/bkg_body-bottom.gif);
height: 100%;
}
</style>
...........

</html>


But when loaded at the browser there´s no line like:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
And the browser sets the default encoding setted (which is a problem to the user when I need to use special characters).

Is there a way to set that in application.ini and use at the application?

Thanks a lot,

2009/10/22 Hector Virgen <djvirgen@gmail.com>

That setting is used by the escape view helper. Where are you seeing that the encoding is not UTF-8?

--
Hector



On Thu, Oct 22, 2009 at 11:21 AM, Andre Fernandes <fernandes.andre@gmail.com> wrote:
Hi,
I am trying to set the page encoding to UTF-8 using the following line at application.ini:

resources.view.encoding = "UTF-8"

,my Bootstrap.php is the following:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    public function _initAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(
            array(
                'namespace' => '',
                'basePath' => APPLICATION_PATH
            )
        );
       
        return $autoloader;
    }
   
    public function _initLayouts()
    {
        Zend_Layout::startMvc();
        $this->getPluginResource('frontController')
            ->getFrontController()
            ->registerPlugin(new Plugin_ModuleLayout());
    }
   
    protected function _initDoctype()
  {
        $this->bootstrap('view');
      $view = $this->getResource('view');
      $view->doctype('XHTML1_STRICT');
  }  
}


And my layout.phtml is the following:

<?php echo $this->docType(); ?>
<html>
<head>
  <?php echo $this->headMeta(); ?>
    <?php echo $this->headTitle(); ?>
    <?php echo $this->headLink(); ?>
    <?php echo $this->headStyle(); ?>
    <?php echo $this->headScript(); ?>
    <?php echo $this->headLink()->appendStylesheet('/css/global.css') ?>
</head>
<body>
    <?php echo $this->layout()->content ?>
</body>
</html>

But the encoding is not being setted at the HTML page generated. I guess there´s something I am missing that is needed to use the encoding setted at application.ini, but I can not find out what.
Any help would be great.

Thanks in advance,

--
André de Camargo Fernandes






--
André de Camargo Fernandes






--
André de Camargo Fernandes






--
André de Camargo Fernandes






--
André de Camargo Fernandes


没有评论: