Here users from all over the world gather around to learn the latest about Chevereto and contribute with ideas to improve the software.
Please keep in mind:
Support response
Support checklist
// Website privacy mode
if(getSetting('website_privacy_mode') == 'private' and !Login::getUser()) {
$allowed_requests = ['<name-of-custom-route>','api', 'login', 'logout', 'image', 'album', 'page', 'account', 'connect'];
if(getSetting('enable_signups')) {
$allowed_requests[] = 'signup';
}
if(!in_array($handler->request_array[0], $allowed_requests)) {
G\redirect('login');
}
}
<?php
$route = function($handler) {
try {
$list = new CHV\Listing;
$list->setType('albums');
$list->setWhere('WHERE album_user_id = :user_id'); // Get albums that belong to the user_id = X
$list->bind(':user_id', 1); // Bind to user_id = 1
$list->setLimit(100); // how many results?
$list->setSortType('date'); // date | size | views
$list->setSortOrder('desc'); // asc | desc
$list->exec();
G\Render\json_output($list->output);
} catch(Exception $e) {
G\exception_to_error($e);
}
};
var_dump($safe_html_album['name']);
foreach ($album_images as $album_image_url) {
var_dump($album_image_url['image']['url']);
}
<?php
$route = function($handler) {
try {
// Get categories
$categories = CHV\DB::queryFetchAll("SELECT category_id, category_name, category_url_key FROM chv_categories");
// Get all images in each category
foreach ($categories as $category) {
// Query fetch for all albums in each category
$cat_id = $category['category_id'];
$album_ids_per_cat = CHV\DB::queryFetchAll("SELECT DISTINCT(image_album_id) FROM chv_images WHERE image_category_id=$cat_id");
var_dump($album_ids_per_cat);
foreach ($album_ids_per_cat as $album_id) {
$album_current = CHV\Album::getSingle($album_id['image_album_id']);
$safe_html_album = G\safe_html($album_current);
// List of images in album
$list_params = CHV\Listing::getParams(); // Use CHV magic params
$type = 'images';
$where = 'WHERE image_album_id=:image_album_id';
$list = new CHV\Listing;
$list->setType($type); // images | users | albums
$list->setOffset($list_params['offset']);
$list->setLimit('300');
$list->setItemsPerPage($list_params['items_per_page']); // must
$list->setSortType($list_params['sort'][0]); // date | size | views
$list->setSortOrder('asc'); //asc sort order
$list->setOwner($album_current["user"]["id"]);
$list->setRequester(CHV\Login::getUser());
$list->setWhere($where);
$list->setPrivacy($album_current["privacy"]);
$list->bind(":image_album_id", $album_current["id"]);
$list->output_tpl = 'album/image';
$list->exec();
$album_images = $list->output_assoc;
var_dump($safe_html_album['name']);
foreach ($album_images as $album_image_url) {
var_dump($album_image_url['image']['url']);
}
} /* foreach $album_ids_per_cat END */
} /* foreach $categories END */
} catch(Exception $e) {
G\exception_to_error($e);
}
};
?>
All Chevereto DB methods use PDO so in this case ":" is used to bind parameters.1. What does the : in front of a variable mean?
Is a handler for the default PDO bindling handler.2. What does $list->bind do?
JSON is an standard way used to transmit data. PHP can understand it using json_decode().I'm not familiar with how to work with json, but I'm trying to figure it out for my data export once I got the query output to work.
An album could have multiple images that belong to different categories. You shouldn't assign an album to any category.I'm looping through categories so that I can figure out which album belong to which category.
You are using things that you don't need. For example, you don't need to set the requester, you don't need to issue a query to get the available categories (look for app/loader.php), you don't need to set the privacy, etc. Everytime you remove things that you don't need then you will always have less trouble.Are you able to help me out with what might be wrong?