Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Embargo/Expiry module and site search results


Go to End


2 Posts   1158 Views

Avatar
Bert

Community Member, 19 Posts

22 April 2010 at 5:00am

Is it possible to remove pages that should not be shown (defined by the Embargo/Expiry module) from the site search results? I tried the following, but I am still getting pages that should not be shown:

function results($data, $form)
{
	$results = $form->getResults();
	
	foreach ($results as $result)
	{
		if ($result->Embargo != NULL && $result->Embargo < strftime('now'))
		{
			$results->remove($result);
		}
		
		if ($result->Expiry != NULL && $result->Expiry >= strftime('now'))
		{
			$results->remove($result);
		}
	}

	$data = array(
		'Results' => $results,
		'Query' => $form->getSearchQuery(),
		'Title' => 'Search Results'
	);

	return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}

Avatar
Bert

Community Member, 19 Posts

12 May 2010 at 8:58pm

No one knows how I can use extra fields in the site search? The Embargo and Expiry fields seem to be accessible, but they are returned empty.