Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 143729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:08:29+00:00 2026-05-11T08:08:29+00:00

Case: you’re developing a site with Zend Framework and need relative links to the

  • 0

Case: you’re developing a site with Zend Framework and need relative links to the folder the webapp is deployed in. I.e. mysite.com/folder online and localhost:8080 under development.

The following works nice in controllers regardless of deployed location:

$this->_helper->redirector->gotoSimple($action, $controller, $module, $params); 

And the following inside a viewscript, ie. index.phtml:

<a href='<?php echo $this->url(array('controller'=>'index', 'action' => 'index'), null, true); ?>'> 

But how do I get the correct basepath when linking to images or stylesheets? (in a layout.phtml file, for example):

<img src='<?php echo WHAT_TO_TYPE_HERE; ?>images/logo.png' /> 

and

$this->headLink()->appendStylesheet( WHAT_TO_TYPE_HERE . 'css/default.css'); 

WHAT_TO_TYPE_HERE should be replaced with something that gives

<img src='/folder/images/logo.png />` on mysite.com and `<img src='/images/logo.png /> 

on localhost

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:08:29+00:00Added an answer on May 11, 2026 at 8:08 am

    You can get the base url from the Front Controller Zend_Controller_Front::getInstance()->getBaseUrl();. I wrap that in a view helper

    class My_View_Helper_BaseUrl  {        /**      *  Get base url      *       * @return string      */     public function baseUrl()     {         return rtrim(Zend_Controller_Front::getInstance()->getBaseUrl(),'/');     }  } 

    So in the html markup you have something like <img src='<?php echo $this->baseUrl();?>/images/logo.png'/> The trailing slash is stripped out in the helper so that when the application isn’t run in a sub folder (baseUrl is blank in that case) the path will still work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using a CASE called MAGIC for a system I'm developing, I've never
Case: I need to feed my application a URL from any location on the
case i of 0..99 : Function-call('bobo') ; 100..209 : function-smell('Hobo'); 210..300 : function-yikes('argh'); end;
The case goes as following: You have a Boolean property called FullScreenEnabled. You enter
Use case: A does something on his box and gots stuck. He asks B
Use case: 3rd party application wants to programatically monitor a text file being generated
Simple case: i put a DataTable in Cache DataTable table = SomeClass.GetTable(); Cache[test] =
In the case of languages that support single decision and action without brackets, such
Kind of a special case problem: I start a process with System.Diagnostics.Process.Start(..) The process
Given the case I made two independent changes in one file: eg. added a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.