maxdome
Chevereto Member
I have read in this forum that the users asked for how to display the albums on the main page.
After two hours of testing and more than 5 days to study the code functions of Chevereto, finally I did it.
What should I know before?
a) This Guide show you step by step how to display the albums page on your home page.
b) This guide process is an extra code and has been tested with Chevereto versión 3.6.x
What are set by default in this guide?
Guests:
1) Albums and images that are hidden by the users are not displayed.
Members:
1) The members can view their own albums.
Admins:
1) Administrators can view hidden albums.
2) Administrators can delete albums.
Others:
1) Code to allow the albums to be displayed only for registered users.
THE PROCESS
Step 1: Creates two files
Step 2: Edit the file: (albums.php) and add this code snippet:
Step 3: Edit the file: (route.albums.php) and add this code snippet:
Option: Only Members
If you want to display albums only to registered users, remove the // in the route.albums.php file:
Step 4 - Upload the files to your Chevereto website (FTP):
Step 5 - Edit the header.php file:
/app/themes/Peafowl/header.php
Search this code snippet:
Add before this code:
Step 6 - Go to your Cheverote MySQL database and insert this sql code:
Step 7 - Now edit the file (dashboard.php) :
/app/themes/Peafowl/views/dashboard.php
Search this code:
add this code snippet below:
Step 8 - Now go to your admin: Dashboard: -> Settings -> Website
On the Albums menu, Select: (Enable) and click on the save button.
Now go to your homepage web and check it.
Online Demo: https://zupics.com/albums
Demo Webpage : #1
Demo Webpage : #2
Demo Mobile: #1
Demo Mobile: #2
If you got it, put your website is this post to see how it looks
If you liked my guide, please click the "like" button
Good Luck
Best Regards:
Gio
After two hours of testing and more than 5 days to study the code functions of Chevereto, finally I did it.
What should I know before?
a) This Guide show you step by step how to display the albums page on your home page.
b) This guide process is an extra code and has been tested with Chevereto versión 3.6.x
What are set by default in this guide?
Guests:
1) Albums and images that are hidden by the users are not displayed.
Members:
1) The members can view their own albums.
Admins:
1) Administrators can view hidden albums.
2) Administrators can delete albums.
Others:
1) Code to allow the albums to be displayed only for registered users.
THE PROCESS
Step 1: Creates two files
Code:
albums.php
route.albums.php
Step 2: Edit the file: (albums.php) and add this code snippet:
PHP:
<?php if(!defined('access') or !access) die('This file cannot be directly accessed.'); ?>
<?php G\Render\include_theme_header(); ?>
<div class="content-width"><div class="form-content">
<?php switch(get_albums()) { case 'albums': global $tabs; $tabs = get_sub_tabs(); ?>
<div class="header header-tabs margin-bottom-10 follow-scroll">
<h1 class="phone-hidden"><?php echo _s('Albums');?></h1>
<?php G\Render\include_theme_file("snippets/tabs"); ?>
<?php global $user_items_editor; $user_items_editor = false; G\Render\include_theme_file("snippets/user_items_editor"); ?>
<div class="header-content-right phone-float-none">
<?php $logged_user = CHV\Login::getUser(); if($logged_user['is_admin']) { G\Render\include_theme_file("snippets/listing_tools_editor"); } ?>
</div></div><div id="content-listing-tabs" class="tabbed-listing">
<div id="tabbed-content-group"><?php G\Render\include_theme_file("snippets/listing"); ?>
</div></div><?php break; } ?></div> </div>
<?php G\Render\include_theme_footer(); ?>
<?php if(get_post() and (is_changed() or is_error())) { ?>
<script>PF.fn.growl.expirable("<?php echo is_changed() ? (get_changed_message() ? get_changed_message() : _s('Changes have been saved.')) : _s('Check the errors to proceed.'); ?>");</script>
<?php } ?>
Step 3: Edit the file: (route.albums.php) and add this code snippet:
PHP:
<?php
$route = function($handler) {
try {
if($_POST and !$handler::checkAuthToken($_REQUEST['auth_token'])) {
$handler->template = 'request-denied';
return;
}
$logged_user = CHV\Login::getUser();
$route_prefix = 'albums';
$sub_routes = [
'albums' => _s('Albums')
];
//##Display albums only to registered members##
//If you want to display albums only to registered users, remove the // in the code below:
//if(!$logged_user) { G\redirect(G\get_base_url('login')); }
if(!CHV\getSetting('website_albums_page')) {
return $handler->issue404();
}
$default_route = 'albums';
$doing = $handler->request[0];
if(!is_null($doing) and !array_key_exists($doing, $sub_routes)) {
return $handler->issue404();
}
if($doing == '') $doing = $default_route;
foreach($sub_routes as $route => $label) {
$aux = str_replace('_', '-', $route);
$handler::setCond($route_prefix.'_'.$aux, $doing == $aux);
if($handler::getCond($route_prefix.'_'.$aux)) {
$handler::setVar($route_prefix, $aux);
}
$route_menu[$route] = array(
'label' => $label,
'url' => G\get_base_url($route_prefix . ($route == $default_route ? '' : '/'.$route)),
'current' => $handler::getCond($route_prefix.'_'.$aux)
);
}
$handler::setVar($route_prefix.'_menu', $route_menu);
$handler::setVar('tabs', $route_menu);
$is_error = false;
$is_changed = false;
$input_errors = array();
$error_message = NULL;
$image_size_count_qry = version_compare(CHV\getSetting('chevereto_version_installed'), '3.5.5', '<') ? 'SELECT SUM(image_size) as count' : 'SELECT (SUM(image_size) + SUM(image_thumb_size) + SUM(image_medium_size)) as count';
switch($doing) {
case 'albums':
$tabs = [
[
'list' => true,
'tools' => true,
'label' => _s('Most recent'),
'id' => 'list-most-recent',
'params' => 'list=albums&sort=date_desc&page=1',
'current' => $_REQUEST['sort'] == 'date_desc' or !$_REQUEST['sort'] ? true : false,
],
[
'list' => true,
'tools' => true,
'label' => _s('Oldest'),
'id' => 'list-most-oldest',
'params' => 'list=albums&sort=date_asc&page=1',
'current' => $_REQUEST['sort'] == 'date_asc',
]
];
$type = $doing;
$current = false;
foreach($tabs as $k => $v) {
if($v['current']) {
$current = $k;
}
$tabs[$k]['type'] = $type;
$tabs[$k]['url'] = G\get_base_url('albums/'.$type.'/?' . $tabs[$k]['params']);
}
if(!$current) {
$current = 0;
$tabs[0]['current'] = true;
}
$list_params = CHV\Listing::getParams();
parse_str($tabs[$current]['params'], $tab_params);
preg_match('/(.*)_(asc|desc)/', !empty($_REQUEST['sort']) ? $_REQUEST['sort'] : $tab_params['sort'], $sort_matches);
$list_params['sort'] = array_slice($sort_matches, 1);
$list = new CHV\Listing;
$list->setType($type); $list->setOffset($list_params['offset']);
$list->setLimit($list_params['limit']); $list->setItemsPerPage($list_params['items_per_page']); $list->setSortType($list_params['sort'][0]); $list->setSortOrder($list_params['sort'][1]); $list->setRequester($logged_user );
$list->output_tpl = $type;
$list->exec();
break;
}
$handler::setVar('pre_doctitle', _s('Albums'));
$handler::setCond('error', $is_error);
$handler::setCond('changed', $is_changed);
$handler::setVar('error', $error_message);
$handler::setVar('input_errors', $input_errors);
$handler::setVar('changed_message', $changed_message);
if($tabs) {
$handler::setVar('sub_tabs', $tabs);
}
if($list) {
$handler::setVar('list', $list);
}
} catch(Exception $e) {
G\exception_to_error($e);
}
};
Option: Only Members
If you want to display albums only to registered users, remove the // in the route.albums.php file:
Code:
//if(!$logged_user) {
//G\redirect(G\get_base_url('login'));
//}
Step 4 - Upload the files to your Chevereto website (FTP):
Code:
/app/themes/Peafowl/views/albums.php
/app/routes/route.albums.php
Step 5 - Edit the header.php file:
/app/themes/Peafowl/header.php
Search this code snippet:
Code:
<?php if(CHV\getSetting('website_search')) { ?>
Add before this code:
PHP:
<!--//Start Code New Albums List -->
<?php if(CHV\getSetting('website_albums_page')) { ?>
<li id="top-bar-albums" data-nav="albums" class="top-btn-el">
<a href="<?php echo G\get_base_url("albums"); ?>"><span class="top-btn-text"><span class="icon icon-images"></span><span class="btn-text phone-hide phablet-hide"><?php _se('Albums'); ?></span></span></a>
</li>
<?php } ?>
<!--//End Code New Albums List -->
Step 6 - Go to your Cheverote MySQL database and insert this sql code:
Code:
INSERT INTO `chv_settings` (`setting_id`, `setting_name`, `setting_value`, `setting_default`, `setting_typeset`) VALUES
('', 'website_albums_page', '0', '0', 'bool');
Step 7 - Now edit the file (dashboard.php) :
/app/themes/Peafowl/views/dashboard.php
Search this code:
Code:
<div class="input-below"><?php _se('Enable this if you want to allow the explore page.'); ?></div>
</div>
add this code snippet below:
PHP:
<!--//Start Code: Display Albums Page in Homepage-->
<div class="input-label">
<label for="website_albums_page"><?php _se('Albums'); ?></label>
<div class="c5 phablet-c1"><select type="text" name="website_albums_page" id="website_albums_page" class="text-input">
<?php
echo CHV\Render\get_select_options_html([1 => _s('Enabled'), 0 => _s('Disabled')], CHV\Settings::get('website_albums_page'));
?>
</select></div>
<div class="input-below"><?php _se('Enable this if you want to allow the albums page.'); ?></div>
</div>
<!--//End Code: Display Albums Page in Homepage-->
Step 8 - Now go to your admin: Dashboard: -> Settings -> Website
On the Albums menu, Select: (Enable) and click on the save button.
Now go to your homepage web and check it.
Online Demo: https://zupics.com/albums
Demo Webpage : #1
Demo Webpage : #2
Demo Mobile: #1
Demo Mobile: #2
If you got it, put your website is this post to see how it looks
If you liked my guide, please click the "like" button
Good Luck
Best Regards:
Gio
Last edited: