When we are discussing about this...here is the case:
you have a form

<form id="search" method="get" action="<?= $this->url()) ?>">
...
</form>

When you submit this form you get query string in your url, is there a way
to make it /name/param/... and not ?name=param...?
O.K. One option is javascript...another problem is that url helpers does not
honor query string params, I've made helper to do this

class Umpirsky_View_Helper_Qurl extends Zend_View_Helper_Abstract {
/**
     * Generates an url given the name of a route.
     *
     * @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 qurl(array $urlOptions = array(), $name = null, $reset =
false, $encode = true) {
     $url = $this->view->url($urlOptions, $name, $reset, $encode);
        $requestUri =
Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
        $query = parse_url($requestUri, PHP_URL_QUERY);
        if($query != '') {
         $url .= '/';
         $pairs = explode('&', $query);
         foreach ($pairs as $pair) {
         $url.= str_replace('=', '/', $pair) . '/';
         }
        }

        return $url;
    }
}

but I don't think this is a way to go and this does not solve non-zf urls
after get form submit, any tips?

Regards,
Saša Stamenković


On Wed, Aug 5, 2009 at 10:05 AM, Matt Pearson <mpear...@lizearle.com> wrote:

> Hi There,
>
> This sounds like a problem I was struggling with recently when I was
> also deploying Zend_Paginator on a search results page.
>
>
> >1. $this->getRequest()->getParams() returns too much info, such as
> >controller, action and module. I need just my parameters and I don't
> know
> >how to do this with Zend.
>
> getParams() receives data from multiple sources and sometimes isn't
> exactly  what you need getQuery() will provide you with the $_GET
> variables only, or you could use setParamSources() to limit what you
> receive from getParams()
>
>
> >2. In my test, instead of having the proper URL even for search_text I
> >have:
> >http://quickstart/data/index/page/2/0/search_text
> >
> >There is an extra "0" and no "search" thus I am handling this array
> wrong.
>
> Remember that calls to $this->url() from the pagination partial will
> take into account any routes that you defined in your front controller.
> In effect, you are sending the array (
>                                                [page]  => 2,
>                                                [0]  => 'search_text'
>                                                )
> to your default route.
>
>
> >3. My tests only allow one parameter, I would really like to send all
> >three.
>
> You can easily set up a custom router that can take those three
> parameters. I only needed to include two, but this is what I did for
> mine
>
>
> In the front controller:
> ------------------------
>
> $router = $front->getRouter();
>
>
> $route = new
> Zend_Controller_Router_Route_Regex('search/([^\/]*)(/([0-9]*))?',
>    array(
>        'module' => 'search',
>        'controller' =>'index',
>        'action' =>'results'
>    ),
>    array(
>        1 => 'q',
>        2 => 'page'
>    ),
>    "search/%s/%s"
> );
>
> $router->addRoute('search', $route);
>
> In my Paginator partial:
> ------------------------
>
>
> <!-- Next page link -->
> <?php if (isset($this->next)): ?>
>   <a href="<?php echo $this->url(array('q' => $this->urlQuery,'page' =>
> $this->next)); ?>">
>    Next &gt;
>  </a>
> <?php else: ?>
>  <span class="disabled">Next &gt;</span>
> <?php endif; ?>
>
>
>
> I hope that's some help. There is no need to use sessions to do this.
>
>
> Matt
>
>
> Matt Pearson
> Internet Solutions Developer
> Liz Earle Beauty Co.
>
>
> -----Original Message-----
> From: eugenevdm [mailto:eug...@snowball.co.za]
> Sent: 04 August 2009 17:34
> To: fw-general@lists.zend.com
> Subject: Re: [fw-general] What is the fourth parameter of pagination
> control?
>
>
> With regarding to Zend Pagination Control's fourth parameter:
>
>
> Customize wrote:
> >
> >
> > What can we pass there as an additional parameters? URL encoded data
> > like search form data as an array? Where do we retrieve this fourth
> > parameter and how? (view partial script of paginator control? how?)
> >
> >
>
> I have the same application as this user, I want to "carry over" URL
> parameters with the pagination control for searching, filtering, and
> custom
> use.
>
> I nearly have this figured out but in the absence of a good example I
> cannot
> get it working.
>
> To test it I have tried this in my script when setting up a
> paginationControl:
>
> <?= $this->paginationControl($this->paginator, 'Sliding',
> 'partials/pagination.phtml', array("search" => "search_text")); ?>
>
> What I actually want to carry over from page to page is a URL parameters
> equal to:
>
> ?search=search_text&filter=custom_filter&custom=my_custom_command
>
> I thought in my controller I could do this:
>
> $url_params = $this->getRequest()->getParams();
> $this->view->url_params = $url_params;
>
> And then send this somehow as an array to my partial.
>
> In my test for partial I have this (testing on the 'next' link,
> presumably
> I'm going to have to incorporate this on *every* link):
>
> <!-- Next page link -->
>        <?php if (isset($this->next)): ?>
>                |  "<?= $this- url(array('page' => $this->next,
> $this->search)); ?>">Next
> &gt;  |
>        <?php else: ?>
>                | Next &gt; |
>        <?php endif; ?>
>
>
> Multiple problems:
>
> 1. $this->getRequest()->getParams() returns too much info, such as
> controller, action and module. I need just my parameters and I don't
> know
> how to do this with Zend.
>
> 2. In my test, instead of having the proper URL even for search_text I
> have:
> http://quickstart/data/index/page/2/0/search_text
>
> There is an extra "0" and no "search" thus I am handling this array
> wrong.
>
> 3. My tests only allow one parameter, I would really like to send all
> three.
>
> I would prefer not to use sessions as per the other suggestions if Zend
> already has this built in.
>
> Please assist.
> --
> View this message in context:
> http://www.nabble.com/What-is-the-fourth-parameter-of-pagination-control
> --tp22051496p24811928.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>
>
> Work with the environment... think before you print
>
> Liz Earle Naturally Active Skincare
> The Green House  Ryde IOW  PO33 1BD
>
> Telephone +44 (0)1983 813913. Fax +44 (0)1983 813912.
> Email naturallyact...@lizearle.com <mailto:naturallyact...@lizearle.com>
>  Web www.lizearle.com <http://www.lizearle.com>
> Liz Earle Naturally Active Skincare is a trading name of Liz Earle Beauty
> Co. Limited.
> Registered in England No. 3070395 Registered address: 5 Fleet Place,
> London,  EC4M 7RD.
>

Reply via email to