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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:31:56+00:00 2026-05-13T11:31:56+00:00

I’m using Zend-Framework 1.9.5 to make a web-application, But it’s Url_Helper was quite tricky

  • 0

I’m using Zend-Framework 1.9.5 to make a web-application, But it’s Url_Helper was quite tricky to me in the matter of parameter reset!, I know it’s a good feature (parameter preserving) but in most cases I don’t need it!.
So I’m thinking of overriding the default Router to force it loosing parameters Unless I ask for it or maybe specifying a certain parameters that it keeps like (lang, or something like that).

Also I want to make it the default router so I don’t have to edit my Controllers, Views to get that done!

Any suggestions?

Update:
I spent the whole morning trying to write my url helper Admin_View_Helper_Xurl, But I couldn’t do anything that solves the problem:

<?php
class Admin_View_Helper_Xurl extends Zend_View_Helper_Abstract
{
     public function xurl(array $urlOptions = array(), $name = 'default', $reset = false, $encode = true)
    {
        $router = Zend_Controller_Front::getInstance()->getRouter();

        $wanted_params = array('module', 'controller', 'action', 'lang', 'page', 'search');

        $route = $router->getCurrentRoute();

        $something = anyWayToGetThatObjectOrClass();

        $params = $something->getParams();

        foreach($params as $key => $val) {
            if (!in_array($key, $wanted_params)) {
                $params[$key] = null; // OR uset($params[$key]);
            }
        }

        $something->clearParams();
        $something->setParams($params);

        return $router->assemble($urlOptions, $name, $reset, $encode);
    }
}

I tried to get current URL parameters and filter them and clear the current parameters and pass my filtered ones but I couldn’t do anything that does it without hard-code editing one Zend_Framework code :(.

Thanks

  • 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-13T11:31:56+00:00Added an answer on May 13, 2026 at 11:31 am

    I came up with this solution. It took 7 hours to be functional.

    class Zend_View_Helper_Xurl extends Zend_View_Helper_Abstract
    {
    
        const RESET_ALL = 'all';
        const RESET_CUSTOM = 'normal';
        const RESET_NON_MVC = 'mvc';
        const RESET_NONE = 'none';
    
    
        protected $_wantedParams = array('module', 'controller', 'action', 'lang', 'page', 'search');
        protected $_router;  
        /**
         * Generates an url given the name of a route.
         *
         * @access public
         *
         * @param  array $urlOptions Options passed to the assemble method of the Route object.
         * @param  mixed $name The name of a Route to use. If null it will use the current Route
         * @param  bool $reset Whether or not to reset the route defaults with those provided
         * @return string Url for the link href attribute.
         */
    
        public function __construct()
        {
            $router = Zend_Controller_Front::getInstance()->getRouter();
            $this->_router = clone $router;
        }
    
        public function xurl(array $urlOptions = array(), $reset = 'mvc', $encode = true)
        {
            $urlOptions = $this->_getFilteredParams($urlOptions, $reset);
            return $this->_router->assemble($urlOptions, $name, true, $encode);
        }
    
        protected function _getFilteredParams($data = array(), $level)
        {
            // $filteredValues = array();
            $request = Zend_Controller_Front::getInstance()->getRequest();
            $filteredValues = $request->getUserParams();
            $$filteredValues['module']     = $request->getModuleName();
            $$filteredValues['controller'] = $request->getControllerName();
            $$filteredValues['action']     = $request->getActionName();
    
    
            switch ($level) {
                case self::RESET_ALL:
                    $filteredValues['module'] = null;
                    $filteredValues['controller'] = null;
                    $filteredValues['action'] = null;
                // break omitted intentionally
                case self::RESET_NON_MVC:
                    $filteredValues['page'] = null;
                    $filteredValues['lang'] = null;
                    $filteredValues['search'] = null;
                // break omitted intentionally
    
                case self::RESET_CUSTOM:
                    foreach ($filteredValues as $key=>$val) {
                        if (!in_array($key, $this->_wantedParams)) {
                            $filteredValues[$key] = null;
                        }
                    }
                    break;
                case self::RESET_NONE:
                    break;
    
                default:
                    throw new RuntimeException('Unsuppoted Xurl URL helper reset level.');
                    break;
            }
    
    
            foreach ($filteredValues as $key => $val) {
                if (!array_key_exists($key, $data)) {
                    $data[$key] = $val;
                }
            }
    
            return $data;
        }
    }
    

    Clearly it’s a View Helper class, may be not the best solution but it works fine with me for now.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build

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.