The user is not interested in this, but I was, so I
included it as a comment so that I could inspect it using the view source command whilst investigating various
search queries. Obviously, this can be removed from a production application.
Listing 8.12: Displaying error messages from Zend_Filter_Input
function getSearchResultUrl($class, $id)
{
$baseUrl = $this->_view->baseUrl;
$id = (int)$id; A
$class = strtolower($class); A
$url = $baseUrl . "/$class/index/id/$id";
return $url;
}
A Ensure the parameters are ???sane???
The initial version of getSearchResultUrl() is very simple as there is a one-to-one mapping from the
model??™s class name to controller action. That is, for a model called Places, the controller used is places/index.
It is likely that this would change as more models are introduced into the application. As this happens the
complexity of mapping from model to the URL will increase and be completely contained within the view
helper. This will help make long term maintenance that much easier.
8.5 Summary
This chapter has introduced one of the exceptional components of the Zend Framework. Zend_Search_Lucene
is a very comprehensive full text search engine written entirely in PHP and easily enables a developer to add a
search facility to a website.
Pages:
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243