2008年11月24日星期一

[fw-mvc] Re: How to get base URL; WAS Re: [fw-mvc] Zend_Form_Element_Multi addMultiOptions() performance

Miguel --

When you want to post to the list, please either send the email to the
appropriate list address or change the subject. What you did here is
what's called "thread hijacking". Thread hijacking is bad, as it
mischaracterizes what you're emailing about -- which can lead to lack of
response (people may not have an answer or be interested in the original
subject, and skip over your mail), and inability to search for
appropriate answers (due to being sorted by subject).

I'm answering to you below...

-- Miguel Vieira Dr. (e-mail pessoal) <vieira@miguelvieira.com.pt> wrote
(on Monday, 24 November 2008, 11:25 PM -0000):
> I have some problems with my layout, styles don't work...
>
> <head>
> <?= $this->headTitle(); ?>
>
> <?= $this->headMeta(); ?>
>
> <link rel="shortcut icon" href="<?= $this->baseUrl; ?>/images/favicon.ico" type="image/vnd.microsoft.icon">
> <link href="<?= $this->baseUrl; ?>/styles/reset.css" rel="stylesheet" type="text/css" media="screen">
> <link href="<?= $this->baseUrl; ?>/styles/estilos.css" rel="stylesheet" type="text/css" media="screen">
> <!--[if IE 7]>
> <link href="<?= $this->baseUrl; ?>/styles/estilosie7.css" rel="stylesheet" type="text/css" media="screen" />
> <![endif]-->
>
> <script src="<?= $this->baseUrl; ?>/js/mootools.js" type="text/javascript"></script>
> <script src="<?= $this->baseUrl; ?>/js/validation.js" type="text/javascript" ></script>
> <script type="text/javascript">
> window.addEvent('domready', function(){
> var accordion = new Accordion('h3.atStart', 'ul.atStart', {
> opacity: false
> }, $('accordion'));
> });
> </script>
> </head>
>
>
> If I remove slash ("/") works...
>
> Example:
>
> <link href="<?= $this->baseUrl; ?>styles/estilos.css" rel="stylesheet" type="text/css" media="screen">
>
>
> My base url don't work on windows.. (wamp) and work on Mac (Mamp)
>
> $baseUrl = substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], '/index.php'));

I'd personally grab this information from the request object:

$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();

This will be properly formatted, and *omit* the trailing '/'
consistently. (i.e., your URLs should *include* the slash)

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

没有评论: