Prev | Current Page 346 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

($this->mAllWords == 'on' ? 'all' : 'any') . ''
. ' of these words: '
. implode(', ', $search_results['accepted_words']) .
'

';
if (count($search_results['ignored_words']) > 0)
$this->mSearchDescription .=
'

Ignored words: '
. implode(', ', $search_results['ignored_words']) .
'

';
CHAPTER 8 ?–  SEARCHING THE CATALOG 243
if (!(count($search_results['products']) > 0))
$this->mSearchDescription .=
'

Your search generated no results.

';
}
/* If browsing a category, get the list of products by calling
the GetProductsInCategory business tier method */
elseif (isset ($this->_mCategoryId))
$this->mProducts = Catalog::GetProductsInCategory(
$this->_mCategoryId, $this->mPage, $this->mrTotalPages);
...
5. Continue by updating the init() method as highlighted, to add navigation links on search results pages:
...
/* If there are subpages of products, display navigation
controls */
if ($this->mrTotalPages > 1)
{
// Build the Next link
if ($this->mPage < $this->mrTotalPages)
{
if (isset($_GET['SearchResults']))
$this->mLinkToNextPage =
Link::ToSearchResults($this->mSearchString, $this->mAllWords,
$this->mPage + 1);
elseif (isset($this->_mCategoryId))
$this->mLinkToNextPage =
Link::ToCategory($this->_mDepartmentId, $this->_mCategoryId,
$this->mPage + 1);
elseif (isset($this->_mDepartmentId))
$this->mLinkToNextPage =
Link::ToDepartment($this->_mDepartmentId, $this->mPage + 1);
}
// Build the Previous link
if ($this->mPage > 1)
{
if (isset($_GET['SearchResults']))
$this->mLinkToPreviousPage =
Link::ToSearchResults($this->mSearchString, $this->mAllWords,
$this->mPage - 1);
elseif (isset($this->_mCategoryId))
$this->mLinkToPreviousPage =
Link::ToCategory($this->_mDepartmentId, $this->_mCategoryId,
$this->mPage - 1);
elseif (isset($this->_mDepartmentId))
$this->mLinkToPreviousPage =
CHAPTER 8 ?–  SEARCHING THE CATALOG 244
Link::ToDepartment($this->_mDepartmentId, $this->mPage - 1);
}
// Build the pages links
for ($i = 1; $i <= $this->mrTotalPages; $i++)
if (isset($_GET['SearchResults']))
$this->mProductListPages[] =
Link::ToSearchResults($this->mSearchString, $this->mAllWords, $i);
elseif (isset($this->_mCategoryId))
$this->mProductListPages[] =
Link::ToCategory($this->_mDepartmentId, $this->_mCategoryId, $i);
elseif (isset($this->_mDepartmentId))
$this->mProductListPages[] =
Link::ToDepartment($this->_mDepartmentId, $i);
else
$this->mProductListPages[] = Link::ToIndex($i);
}
.


Pages:
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358