<?php
$route = function($handler) {
try {
$username = $handler->request[0]; // Gets 'newmedia' user (string) from http://vr.newmediaart.co/newmedia
$user = CHV\User::getSingle($username, 'username'); // Gets user details by username
if(!$user) {
$handler->issue404();
}
$list = new CHV\Listing; // Creates a new Listing object
$list->setType('images'); // You want to get images
$list->setOffset(0); // Starer pointer, used when you paginate results
$list->setLimit(1); // how many results?
$list->setItemsPerPage(1); // Limit same as the results
$list->setSortType('date'); // Sort criteria: date | size | views
$list->setSortOrder('desc'); // Sort order: asc | desc
$list->setWhere('WHERE image_user_id=:user_id');
$list->bind(":user_id", $user['id']); // Numeric user ID (or true ID)
$list->exec();
$vroutput = '';
foreach($list->output_assoc as $k => $v) {
$vroutput .= '<a-image src="'.$v['display_url'].'" rotation="0 0 0" position="0 2 -11.4"></a-image>' . "\n";
}
$handler->setVar('vroutput', $vroutput); // use it in the theme file with echo get_vroutput();
} catch(Exception $e) {
G\exception_to_error($e);
}
};