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 742689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:46:36+00:00 2026-05-14T08:46:36+00:00

Am creating an action helper that will require the return value of the Zend_View_Helper_BaseUrl

  • 0

Am creating an action helper that will require the return value of the

Zend_View_Helper_BaseUrl

How do I go about that?

  • 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. Editorial Team
    Editorial Team
    2026-05-14T08:46:37+00:00Added an answer on May 14, 2026 at 8:46 am

    $this->view->baseUrl() should work.

    But I suggest creating new action helper, which is basically a copy of view helper, but you may modify to suit your needs:

    /**
     * Generate URL of the current domain
     *
     */
    class My_Controller_Action_Helper_BaseUrl
    extends Zend_Controller_Action_Helper_Abstract
    {
        public function direct($file = null, $full = true)
        {
            return $this->baseUrl($file, $full);
        }
    
        /**
         * BaseUrl
         *
         * @var string
         */
        protected $_baseUrl;
    
        /**
         * Returns site's base url, or file with base url prepended
         *
         * $file is appended to the base url for simplicity
         *
         * @param  string|null $file
         * @return string
         */
        public function baseUrl($file = null)
        {
            // Get baseUrl
            $baseUrl = $this->getBaseUrl();
    
            // Remove trailing slashes
            if (null !== $file) {
                $file = '/' . ltrim($file, '/\\');
            }
    
            return $baseUrl . $file;
        }
    
        /**
         * Set BaseUrl
         *
         * @param  string $base
         * @return My_Controller_Action_Helper_BaseUrl
         */
        public function setBaseUrl($base)
        {
            $this->_baseUrl = rtrim($base, '/\\');
            return $this;
        }
    
        /**
         * Get BaseUrl
         * @return string
         */
        public function getBaseUrl()
        {
            if ($this->_baseUrl === null) {
                /** @see Zend_Controller_Front */
                require_once 'Zend/Controller/Front.php';
                $baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
    
                // Remove scriptname, eg. index.php from baseUrl
                $baseUrl = $this->_removeScriptName($baseUrl);
    
                $this->setBaseUrl($baseUrl);
            }
    
            return $this->_baseUrl;
        }
    
        /**
         * Remove Script filename from baseurl
         *
         * @param  string $url
         * @return string
         */
        protected function _removeScriptName($url)
        {
            if (!isset($_SERVER['SCRIPT_NAME'])) {
                // We can't do much now can we? (Well, we could parse out by ".")
                return $url;
            }
    
            if (($pos = strripos($url, basename($_SERVER['SCRIPT_NAME']))) !== false) {
                $url = substr($url, 0, $pos);
            }
    
            return $url;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a msi based installer (using InstallShield) that has a custom action to
I'm trying to start a new user session by creating a helper that POSTs
I have trouble creating a Catalyst action that would match a single file in
I'm interested in creating an action for the admin interface that requires some additional
Can I access my action helpers from my models? What am avoiding is creating
This is my first time creating a custom action so I'm a bit lost.
I is it possible to create a url aliasing for a controller/action without creating
I am creating a Facebook open graph action called post. It only appears in
So I am creating a CSV file and everytime an action occurs I would
All my dynamically generated action links etc. are creating links like / A ccount/

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.