Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82185

Merging arrays in php before json output

$
0
0

I'm moving to server-side processing. Usually I'd merge JSON fields with javascript after the file was loaded. I can still do that in SSP, but it breaks up search, since search works in the original fields, and not the actual data in the columns.

To give you an example, I have a column for authors. When there is no author, the output is an editor. When searching, I want to search for people (author/editor), but SSP will only search for one of the two. My solution would be an array merged before the json output, printed to a hidden column, which would be searched.

Can it be done? This is my php file, copied from your SSP example.

$columns = array(
array( 'db' => 'Author', 'dt' => 'authors'),
array( 'db' => 'Editor', 'dt' => 'editor'),
array( 'db' => 'Item Type', 'dt' => 'type'),
array( 'db' => 'Publication Year', 'dt' => 'year' ),
array( 'db' => 'Title', 'dt' => 'title' ),
array( 'db' => 'Publication Title', 'dt' => 'pubtitle' ),
array( 'db' => 'Publisher', 'dt' => 'publisher' ),
array( 'db' => 'Url', 'dt' => 'url'),
array( 'db' => 'DOI', 'dt' => 'doi' ),
array( 'db' => 'Title', 'dt' => 'title' ),
array( 'db' => 'Reviewed Author', 'dt' => 'reviewed' ),
array( 'db' => 'Abstract Note', 'dt' => 'abstract' ),
array( 'db' => 'ISBN', 'dt' => 'isbn' ),
array( 'db' => 'Tags', 'dt' => 'tags'),
array( 'db' => 'Place', 'dt' => 'place' ),
array( 'db' => 'Type', 'dt' => 'genre' ),
array( 'db' => 'Publisher', 'dt' => 'publisher' ),
array( 'db' => 'Pages', 'dt' => 'pages' ),
array( 'db' => 'Volume', 'dt' => 'volume' ),
array( 'db' => 'Issue', 'dt' => 'issue')
);

require( 'ssp.class.php' );

echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns)
);


Viewing all articles
Browse latest Browse all 82185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>