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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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