Capturing Advanced Search Terms

I'm trying to get my advanced search terms with the following:

if (isset($_GET['advanced_search']))  {
    $getItemsParams['advanced_search'] = $_GET['advanced_search'];
}

Basically, I'm trying to add it to the custom next/previous links, which currently capture simple search and sort information. This previous Post shows what it currently looks like. I'm not sure if it should stand on it's own, or if it would be a subset of the $_GET['search'].

The param name for the advanced search terms is just "advanced."

$_GET['advanced'] is an array of search "rows," where each row itself has entries "element_id," "type," and "terms."

Thanks for the quick response. I now have the following at the start of the custom_next_previous function

$getItemsParams = array();
if (isset($_GET['search'])) {
    $getItemsParams['search'] = $_GET['search'];
}
if (isset($_GET['advanced']))  {
    $getItemsParams['advanced'] = $_GET['advanced'];
}
if (isset($_GET['sort_field'])) {
    $getItemsParams['sort_field'] = $_GET['sort_field'];
}
if (isset($_GET['sort_dir'])) {
    $getItemsParams['sort_dir'] = $_GET['sort_dir'];
}
if ($getItemsParams){
$current = item('id');
$list=get_items($getItemsParams,total_results());

foreach ($list as &$value) {
            $itemIds[] = $value->id;
        }

The rest follows this Recipe. However, it does not seem to be accounting for the advanced search when I test it. It just links to the next item in the collection, not the next item in the advanced search. Since $_GET['advanced'] returns an array do I need something different from

if (isset($_GET['advanced']))  {
    $getItemsParams['advanced'] = $_GET['advanced'];
}

This syntax worked well with the strings for search and sort, but would I need to do something different with an array?

When I add print_r($getItemsParams); I get the following when I'm on an item page that was the result of an advanced search:

Array ( [search] => [advanced] => Array ( [0] => Array ( [element_id] => 50 [type] => contains [terms] => mysearchterm)))

It seems that $list=get_items($getItemsParams,total_results()); doesn't understand this array, and when I add a print_r($itemIds); I get every item in our database. I know there must be a way to create a list of items based on the advanced search, I'm assuming that's what happens when I'm on the browse pages after running an advanced search.

While the $_GET param is just 'advanced', what goes into the array is "advanced_search". Haven't tested this, but I think that $getItemsParams should look like:

$getItemsParams = array('advanced_search' => array('element_id'=>50 ,
                                                   'type'=>'contains',
                                                   'terms'=>'mysearchterm'
                                                   )
                        );

Thanks for the reply; it helped point me in the right direction. I tried:

if (isset($_GET['advanced'])) {
$getItemsParams['advanced_search'] = $_GET['advanced'];
}

When I initially did this it was still not working. I had added a conditional statement to get the collection info to the $getItemsParams array. When I did a print_r($getItemsParams) it included something like [search] => [collection]=> in the array, and didn’t work when using an advanced search on a specific field. I noticed if I included a collection limiter in my advanced search, then it would work and successfully keep me within my search results when clicking next and previous. Then I removed the conditional statement for the collection and search fields and tried it with just the code at the beginning of the post. Now it worked if I ran an advanced search with no collection selected, and didn’t work if the collection was selected. I noticed after running an advanced search it had terms, collection, and tags in the url. At this point I figured I just needed to prevent keys from getting set to empty values when populating the $getItemsParams array.

So this is what I have, and it works. Basically in the collection, tags, and advanced search spots, there's an extra conditional statement to determine if these are empty. If you have any more concise ways to write this, I’d appreciate it:

function custom_next_previous()
{
$getItemsParams= array();
if (isset($_GET['search'])) {
    $getItemsParams['search'] = $_GET['search'];
}
if (isset($_GET['collection'])) {
   $collection=$_GET['collection'];
	if(strlen($collection)>0){$getItemsParams['collection'] = $_GET['collection'];}
}
if (isset($_GET['tags'])){
   $tags=$_GET['tags'];
     if(strlen($tags)>0){$getItemsParams['tags']=$_GET['tags'];}
}
if (isset($_GET['advanced'])) {
$advancedsearch=$_GET['advanced'];
if (isset($advancedsearch['element-id'])){
    $getItemsParams['advanced_search'] = $_GET['advanced'];
}
}
if (isset($_GET['sort_field'])) {
    $getItemsParams['sort_field'] = $_GET['sort_field'];
}
if (isset($_GET['sort_dir'])) {
    $getItemsParams['sort_dir'] = $_GET['sort_dir'];
}
if ($getItemsParams){
$current = item('id');
$list=get_items($getItemsParams,total_results());

foreach ($list as &$value) {
            $itemIds[] = $value->id;
        }
        $key = array_search($current, $itemIds);
        if ($key > 0) {
            $previousItem = $list[$key - 1];
            $previousUrl = item_uri('show', $previousItem) . '?' . $_SERVER['QUERY_STRING'];
            echo '<li><a href="' . $previousUrl . '">Previous Item</a></li>';
        }
        if ($key < count($list) - 1) {
            $nextItem = $list[$key + 1];
            $nextUrl = item_uri('show', $nextItem) . '?' . $_SERVER['QUERY_STRING'];
            echo '<li class="next"><a href="' . $nextUrl . '">Next Item</a></li>';
        }
    }
   else {
        echo '<li>'.link_to_previous_item('Previous Item').'</li>';
        echo '<li class="next">'.link_to_next_item('Next Item').'</li>';
    }
}

A few corrections, the first uses the correct syntax to check if the 'element_id' is set:

if (isset($_GET['advanced'])) {
$advancedsearch=$_GET['advanced'];
if (isset($advancedsearch['element_id'])){
    $getItemsParams['advanced_search'] = $_GET['advanced'];
}
}

The second addresses an issue discovered by a coworker. If the simple search field had a blank space in it, an error message "Warning: array_search() [function.array-search]: Wrong datatype for second argument in /home/http/omeka/themes/mytheme/custom.php on line 226" was displayed. So to fix this I added the trim() function to the following:

if (isset($_GET['search'])) {
    $getItemsParams['search'] = trim($_GET['search']);
}

Hi,
I successfully used the Recipe linked in this thread on our 1.5.3 install. I'm trying to replicate the functionality in 2.0.3. Has anyone modified it for the newest version of Omeka?

Jen (AMNH Research Library)