php, and add the highlighted code to the init() method of the Product class.
This enables the continue shopping functionality when we reach a product page from the search results page.
elseif (isset ($continue_shopping['DepartmentId']))
$this->mLinkToContinueShopping =
Link::ToDepartment((int)$continue_shopping['DepartmentId'], $page);
elseif (isset ($continue_shopping['SearchResults']))
$this->mLinkToContinueShopping =
Link::ToSearchResults(
trim(str_replace('-', ' ', $continue_shopping['SearchString'])),
$continue_shopping['AllWords'], $page);
else
$this->mLinkToContinueShopping = Link::ToIndex($page);
}
11. Add the following style to styles/tshirtshop.css file:
.words {
color: #ff0000;
}
12. Load your project in your favorite browser, make an all-words search for ???christmas???, browse to the second
page of results, and expect to see a page such as that in Figure 8-7.
Figure 8-7. Sample TShirtShop search results page
CHAPTER 8 ?– SEARCHING THE CATALOG 247
How It Works: The Searchable Product Catalog
Congratulations, you have a searchable product catalog! There was quite a bit to write, but the code wasn??™t that
complicated, was it?
The list of products is displayed by the products_list template you built in Chapter 5, but now it recognizes if
the Search element is in the query string, in which case it uses the Search() method of the business tier to get
the list of products for the visitor.
Pages:
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361