Skip to content

Instantly share code, notes, and snippets.

@kalamalahala
Last active July 11, 2023 23:51
Show Gist options
  • Save kalamalahala/81c9181df5e7c6d05bee3e24e83be1ad to your computer and use it in GitHub Desktop.
Save kalamalahala/81c9181df5e7c6d05bee3e24e83be1ad to your computer and use it in GitHub Desktop.
Format changed by parameter
<?php
public function get_sub_item( $request ) {
$url = $request->get_url_params();
$view_id = intval( $url['id'] );
$entry_id = intval( $url['s_id'] );
$format = \GV\Utils::get( $url, 'format', 'json' );
if (isset($_GET['gv_response_format'])) {
$format = $_GET['gv_response_format'];
}
$view = \GV\View::by_id( $view_id );
$entry = \GV\GF_Entry::by_id( $entry_id );
if ( $format === 'html' ) {
$renderer = new \GV\Entry_Renderer();
return $renderer->render( $entry, $view, new Request( $request ) );
}
return $this->prepare_entry_for_response( $view, $entry, $request, 'single' );
}
@kalamalahala
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment