Hello,
I finally found a workable solution! After struggling for hours with trying to build a proper SQL syntax (I’d recommend this page https://framework.zend.com/manual/1.10/en/zend.db.select.html for anyone looking to do so), I managed to get rid of the error, but the search was STILL not picking up my query.
I then had another look at search-form.php as you suggested, and instead of building up an array with hidden inputs, etc… I just copied the html output to build a custom form with an option select for Branch of Philosophy in place of text input.
This worked, but kept throwing two problems: the first being that if I didn’t allow for a select default value of “” in [element_id], it kept thinking that I wanted to always search for ‘branch of philosophy’. The second issue had to do with the CSS, since class .search-entry links up with the add/remove a field button. I copy-pasted the following lines:
/* @group ----- Advanced Search Form ----- */
#advanced-search-form {
margin-bottom: 40px;
}
#advanced-search-form .submit {
float: right;
}
#advanced-search-form .search-entry input[type=text],
#advanced-search-form .search-entry select {
width: calc((100% - 2.625em) / 3);
display: inline-block;
margin: 0 3px 0 0;
float: none;
}
and appended -custom to both classes for my search div, which resolved the issue!
Not exactly an ideal workaround with SQL, but functional and plays nicely with other search inputs.
Here’s what my (working!) search-form.php looks like now:
<?php
if (!empty($formActionUri)):
$formAttributes['action'] = $formActionUri;
else:
$formAttributes['action'] = url(array('controller'=>'items',
'action'=>'browse'));
endif;
$formAttributes['method'] = 'GET';
?>
>
<?php echo $this->formLabel('keyword-search', __('Search for Keywords')); ?>
<?php
echo $this->formText(
'search',
@$_REQUEST['search'],
array('id' => 'keyword-search', 'size' => '40')
);
?>
<?php echo __('Narrow by Specific Fields'); ?>
<?php
// If the form has been submitted, retain the number of search
// fields used and rebuild the form
if (!empty($_GET['advanced'])) {
$search = $_GET['advanced'];
} else {
$search = array(array('field'=>'','type'=>'','value'=>''));
}
//Here is where we actually build the search form
foreach ($search as $i => $rows):
//The POST looks like =>
// advanced[0] =>
//[field] = 'description'
//[type] = 'contains'
//[terms] = 'foobar'
//etc ?>
<?php
$htmlfield = "";
$htmlfield .= "";
$htmlfield .= "Select Below ";
$htmlfield .= "Author";
$htmlfield .= "Title";
$htmlfield .= "Dedicatee";
$htmlfield .= "Printer";
$htmlfield .= "Date";
$htmlfield .= "City";
$htmlfield .= "Description";
$htmlfield .= "Branch of philosophy";
$htmlfield .= "Related to Aristotle's...";
$htmlfield .= "Type";
$htmlfield .= "Genre";
$htmlfield .= "Shelfmark";
$htmlfield .= "Has Format";
$htmlfield .= "Related Institution";
$htmlfield .= "Work ID";
$htmlfield .= "Manuscript ID";
$htmlfield .= "Edition ID";
echo $htmlfield;
echo $this->formSelect(
"advanced[$i][type]",
@$rows['type'],
array(
'title' => __("Search Type"),
'id' => null,
'class' => 'advanced-search-type'
),
label_table_options(array(
'contains' => __('contains'),
'does not contain' => __('does not contain'),
'is exactly' => __('is exactly'),
'is empty' => __('is empty'),
'is not empty' => __('is not empty'))
)
);
echo $this->formText(
"advanced[$i][terms]",
@$rows['terms'],
array(
'size' => '20',
'title' => __("Search Terms"),
'id' => null,
'class' => 'advanced-search-terms'
)
);
?>
<?php echo __('Remove field'); ?>
<?php endforeach; ?>
<?php echo __('Add a Field'); ?>
<?php /*
<?php echo $this->formLabel('range', __('Search by a range of ID#s (example: 1-4, 156, 79)')); ?>
<?php
echo $this->formText('range', @$_GET['range'],
array('size' => '40')
);
?>
<?php echo $this->formLabel('collection-search', __('Search By Collection')); ?>
<?php
echo $this->formSelect(
'collection',
@$_REQUEST['collection'],
array('id' => 'collection-search'),
get_table_options('Collection')
);
?>
*/ ?>
<?php echo $this->formLabel('item-type-search', __('Record Type')); ?>
<?php
echo $this->formSelect(
'type',
@$_REQUEST['type'],
array('id' => 'item-type-search'),
get_table_options('ItemType')
);
?>
<?php echo $this->formLabel('item-type-search', __('Branch of Philosophy')); ?>
Select below to specify
Branch of Philosophy
is
Select Below
Logic
Natural Philosophy
—Physics
—Biology
—Astronomy
—Psychology
Moral Philosophy
—Ethics
—Politics
—Economics
Metaphysics
Rhetoric
Poetics
<?php if (!isset($buttonText)) $buttonText = __('Search for items'); ?>
<?php echo js_tag('items-search'); ?>
|
Thanks again for all of your help and input with this!