RE: [fw-general] What is the fourth parameter of pagination control?

2009-08-05 Thread Matt Pearson
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)): ?>
  
Next >
  

  Next >




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:

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)): ?>
|  " $this->next,
$this->search)); ?>">Next
>  |

| Next > |



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.


[fw-general] Migrating to Zend Session

2009-08-04 Thread Matt Pearson
Hi there,

I'm migrating an application from PEAR HTTP_Session to Zend_Session.
Most of the HTTP_Session functionality is replicated in Zend_Session,
but there is one method that I can't think of an equivalent for;
isExpired().

I was rather hoping that Zend_Session would have an isExpired() method,
like Zend_HTTP_Cookie does. 

Can anybody suggest a test I can do on Zend Session, or a session
namespace object to see if the session is expired?

Thanks

Matt

Matt Pearson 
Internet Solutions Developer
Liz Earle Beauty Co.
01983 813884 



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.


RE: [fw-general] Coping with Old-style GET vars.

2009-06-30 Thread Matt Pearson

Hi Everyone,

Thanks for your help. As it turns out, I was doing more than one thing
wrong, but Matthew mentioning getQuery() put me on the right track.

The Framework app that I'm working sits inside a non-framework app,
therefore much of this is specific to the environment I'm working in.
Just in case its any help to anyone else. Here is what I did.

I noticed app.php getting odd URIs like this:

app.php?app/search?q=search+word

This was causing the GET vars from the request to disappear, so I
modified my rewrite rule as follows:

RewriteRule ^/app/(.*) /app.php?$1 [L]

Became:

RewriteRule ^/app/(.*)$ /app.php?%{REQUEST_FILENAME}&%{QUERY_STRING} [L]


I changed my controller to read from getQuery() as well as getParam(),so
that I could read the value of q whichever way it came through.

I then modified the calls to the URL helper in the view to sort out the
Paginator links.

Thanks again

Matt


-Original Message-
From: Matthew Weier O'Phinney [mailto:matt...@zend.com] 
Sent: 26 June 2009 13:04
To: fw-general@lists.zend.com
Subject: Re: [fw-general] Coping with Old-style GET vars.

-- Matt Pearson  wrote
(on Friday, 26 June 2009, 12:36 PM +0100):
> I have a problem with GET forms submitting to controllers within the
> framework.
> 
> I have a GET form in a page outside of the Zend Framework app. It does
a
> normal GET to the search controller of my Framework app like this (I
> have a custom route set up)
> 
> /app/search?q=query
> 
> However, my search controller can't get a value for 'q' and the custom
> routes all seem to strip off the portion of the url after the '?' !

Within your controller, you have a couple of different ways to retrieve
this value:

  * via _getParam: $this->_getParam('q'). This actually proxies to the
request object's getParam() method, which searches first for
parameters matched on the route, then GET, then POST.

  * via the request object's getQuery() method:
$this->getRequest()->getQuery('q');

> How do I get routes like Zend_Controller_Router_Route_Regex to use the
> portion after the '?'

You don't. You'll have to do one of two things:

  * Extend the Regex route to merge $_GET parameters into the array of
matched parameters

  * Create a RewriteCond to match the query string and rewrite the URL:

RewriteCond %{query_string} ^q=([^&]*)$
RewriteRule ^/?app/search  /app/search/q/%1

Note that I haven't tested the above, but the idea is that it
searches for a "q" parameter in URLs with /app/search, and then
rewrites the url to add it into the URL itself.


> I have tried disabling all my routes and using the 'real' Framework
> path. This works:
> 
> /app/search/index/results?q=query
> 
> But then I have the problem that my Zend Paginator links become things
> like:
> 
>  /app/search/index/results/page/1
> 
> Which doesn't work, because it omits the search query.
> 
> When URIs are in /proper/framework/format everything is fine. I've
seen
> people use Javascript to get around this problem, but I don't want to
> make my site Javascript dependent.
> 
> Can anyone help? I'm sure there is something obvious that I'm doing
> wrong.
> 
> For full disclosure; here are my Apache rules:
> 
> RewriteCond %{REQUEST_FILENAME} !-f[OR]
> RewriteCond %{REQUEST_FILENAME} !-d
>  
> RewriteRule ^/app/(.*) /app.php?$1 [L]
> 
> (My front controller defines /app as the BaseUrl)

-- 
Matthew Weier O'Phinney
Project Lead| matt...@zend.com
Zend Framework  | http://framework.zend.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.


[fw-general] Coping with Old-style GET vars.

2009-06-26 Thread Matt Pearson
Hi everyone,

I have a problem with GET forms submitting to controllers within the
framework.

I have a GET form in a page outside of the Zend Framework app. It does a
normal GET to the search controller of my Framework app like this (I
have a custom route set up)

/app/search?q=query

However, my search controller can't get a value for 'q' and the custom
routes all seem to strip off the portion of the url after the '?' !

How do I get routes like Zend_Controller_Router_Route_Regex to use the
portion after the '?'

I have tried disabling all my routes and using the 'real' Framework
path. This works:

/app/search/index/results?q=query

But then I have the problem that my Zend Paginator links become things
like:

 /app/search/index/results/page/1

Which doesn't work, because it omits the search query.

When URIs are in /proper/framework/format everything is fine. I've seen
people use Javascript to get around this problem, but I don't want to
make my site Javascript dependent.

Can anyone help? I'm sure there is something obvious that I'm doing
wrong.

For full disclosure; here are my Apache rules:

RewriteCond %{REQUEST_FILENAME} !-f[OR]
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule ^/app/(.*) /app.php?$1 [L]

(My front controller defines /app as the BaseUrl)

Thanks


Matt Pearson 
Internet Solutions Developer
Liz Earle Beauty Co.
01983 813884



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.


RE: [fw-general] Zend_Search_Lucene get all query terms

2009-05-29 Thread Matt Pearson
Yes, in the end I did find Zend_Search_Lucene_Query::getQueryTerms() ;)

 

Sorry, I've been doing a lot of work in Magento, and its fried my brain
:-(

 

Matt

 

Matt Pearson 

Internet Solutions Developer

Liz Earle Beauty Co.

 

 



From: Matt Pearson [mailto:mpear...@lizearle.com] 
Sent: 28 May 2009 16:59
To: fw-general@lists.zend.com
Subject: [fw-general] Zend_Search_Lucene get all query terms

 

Hi Everyone,

 

I need to pass an array of query terms to another object. Is there a way
of doing this other then iterating through each child query object in
the query and gathering each term from it?

 

It seems like quite an intensive approach to me, but I can't think of
another way to do it.

 

Thanks

 

Matt



Work with the environment... think before you print

Liz Earle Naturally Active Skincare 
The Green House  Ryde IOW  PO33 1BD

Telephone +44 (0)1983 813400. Fax +44 (0)1983 813401. 
Email naturallyact...@lizearle.com  Web 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. 



[fw-general] Zend_Search_Lucene get all query terms

2009-05-28 Thread Matt Pearson
Hi Everyone,

 

I need to pass an array of query terms to another object. Is there a way
of doing this other then iterating through each child query object in
the query and gathering each term from it?

 

It seems like quite an intensive approach to me, but I can't think of
another way to do it.

 

Thanks

 

Matt



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   Web 
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.

[fw-general] contributing to Zend Search Lucene

2009-01-12 Thread Matt Pearson
Hi there,

 

I'm currently working on a search function for my employer using Zend
Search Lucene. The idea is to display search results in much the same
way as Google/Nutch

I've had to extend the existing ZSL code to be able to create 'snippets'
(highlighted document fragments)  with a fragmenter, and some (very
small) changes to the highlighter.

 

I was wondering if this would be of any use to the framework, or whether
somebody is already working on this. I've noticed quite a few people
asking for this kind of functionality on the net.

 

Thanks

 

Matt Pearson 

Internet Solutions Developer

Liz Earle Beauty Co.

01983 813884

 



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: 8-10 New Fetter Lane  
London  EC4A 1RS.