Reply To: Reduplicate by MEOW_FieldSetCollection value on collection

Author Replies
sitesurety # Posted on November 5, 2014 at 8:32 pm

Thanks for the help! Very much appreciated. I want to keep my code as slick and clean as possible.. I like how the MP plugin is very Java collection-ishs.

Two other things I’ve been doing which I’m not entirely happy about:

Creating a multi-dimensional array for all the filtered options by data type, which I then output to a form using a double loop:

$filters = array(
“type” => array(),
“hair” => array(),
“blah” => array()
);

// Loop code with de-dup here as $key
if ($key != “”) {
$filters[“type”][] = $key->person->type->val();
}

Then create a form with all the unique filter options:

<!– Filter form –>
<form action=”” method=”get”>
<?php foreach ($filters as $key => $array) { ?>
<label><?php echo ucwords($key) ?>:<label>
<select name=”<?php echo ucwords($key) ?>”>
<?php foreach ($array as $id => $value) { ?>
<option value=”<?php echo $value ?>”><?php echo $value ?></option>
<?php } ?>
</select>

<?php } ?>
</form>

Then I’ve got some jQuery over the top which responds when an option is selected and posts the updated id => keys via Ajax back to the form, which updates the results table:
$(function() {
$(‘select’).bind(‘change’, function(e) {
$(this).closest(‘form’)
.trigger(‘submit’);

$.ajax({
type: “POST”,
dataType: “json”,
data: JSON.stringify(getValues()),
//dataType: “html”,
cache: false,
success: function(data){
$(“results”).html(data);
}
});
return false;

});

// Return select name and value
function getValues() {
var options = $(‘select’);
var values = $.map(options ,function(option) {
return new Array(new Array(option.name, option.value));
});

return values;
};

});

Ideally, I was thinking of moving the data filtering into the controller (functions.php) file, with different case rules…so I just have to output the view in the template.
Is there any other way master press could optimise this/shorten the code?

Latest From the Blog

MasterPress 1.3.6 is now available

Masterpress 1.3.6 is a compatibility release. It resolves an edge case with shared fieldsets not working for MySQL 8 when the fieldset is limited to more than 1 post type or taxonomy or excluding any post types or taxonomies.

Plugin Requirements

MasterPress requires a minimum of WordPress version 4.9, MySQL 5.6, and PHP version 5.6.20.

We also recommend that PHP is configured to use a memory limit of 64MB per request (128MB may be required for sites with higher complexity).

This plug-in is not compatible with the WordPress.com hosted service.

Three AM