• Welcome to the Chevereto user community!

    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:

    • 😌 This community is user driven. Be polite with other users.
    • 👉 Is required to purchase a Chevereto license to participate in this community (doesn't apply to Pre-sales).
    • 💸 Purchase a Pro Subscription to get access to active software support and faster ticket response times.
  • Chevereto Support CLST

    Support response

    Support checklist

Album Explore Button for everyone

latrox

Chevereto Member
Hello,

can you please help me make an Album Explore Button for everyone.
Like that in the Dashboard.
 
Essentially you only need to copy the $listing call functions bundled in.
 
Sure... listings are made in a very complex way that involves php+html declarations. This helps to make the binding to javascript and allow things like the ajax infinite scroll. If you want to craft your own explorer for albums you should try plating with the /app/themes/Peafowl/explore.php page. For instance you will see this in that file:

PHP:
$type = 'images';

There are 3 possible types: images, albums, users. So the listing in the themes are just an API. You can set anything like how many pages, some parameters, etc. You will also notice that there is a $tabs array that contains things like this:

PHP:
                0 => array(
                    'list'        => true,
                    'tools'        => true,
                    'label'        => _s('Most recent'),
                    'id'        => 'list-most-recent',
                    'params'    => 'list=images&sort=date_desc&page=1',
                    'current'    => $_REQUEST['sort'] == 'date_desc' or !$_REQUEST['sort'] ? true : false,
                ),

Note that list=images is a binding crafted for Javascript. You can change that list=images to list=albums and guess what will happen.

Currently the system is pretty raw and the "params" key with the list=images should be auto or there should be some kind of wrapper function that can put all this together easily, as you may be aware that is always the last thing you do because 99% of the people want features fast so it will be pretty interesting when I will finally be able to re-order things.

Anyway, play around with that and then simply copy explore.php to albums.php and route.explore.php to route.albums.php (or anything you may like) and you will have /albums in your website.
 
Ok let rock :D

create albums.php in app/themes/Peafowl

Code:
<?php if(!defined('access') or !access) die('This file cannot be directly accessed.'); ?>
<?php G\Render\include_theme_header(); ?>

<?php CHV\Render\show_banner('explore_after_top'); ?>

<div class="content-width">
   
    <?php
       
        // Use CHV magic params
        $list_params = CHV\Listing::getParams();
       
        $type = 'albums';
       
        try {
                global $list;
                        $list = new CHV\Listing;
                        $list->setType($type); // images | users | albums
                        $list->setOffset($list_params['offset']);
                        $list->setLimit($list_params['limit']); // how many results?
                        $list->setItemsPerPage($list_params['items_per_page']); // must
                        $list->setSortType($list_params['sort'][0]); // date | size | views
                        $list->setSortOrder($list_params['sort'][1]); // asc | desc
                        $list->setRequester(CHV\Login::getUser());
                        $list->output_tpl = $type;
                        $list->exec();
        } catch(Exception $e) {
            G\exception_to_error($e);
        }
    ?>
   
    <div class="header header-tabs margin-bottom-10 follow-scroll">
        <h1><strong><?php echo get_category() ? get_category()['name'] : _s('Albums'); ?></strong></h1>
        <?php
            global $tabs; // Define it as a global to bind it on the included tab.php
            $tabs = array(
                0 => array(
                    '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,
                ),
                1 => array(
                    'list'        => true,
                    'tools'        => true,
                    'label'        => _s('Oldest'),
                    'id'        => 'list-most-oldest',
                    'params'    => 'list=albums&sort=date_asc&page=1',
                    'current'    => $_REQUEST['sort'] == 'date_asc',
                )
            );
           
            $current = false;
            foreach($tabs as $k => $v) {
               
                if(get_category()) {
                    $tabs[$k]['params_hidden'] .= 'category_id=' . get_category()['id'];
                }
               
                if($v['current']) {
                    $current = true;
                }
                $tabs[$k]['type'] = 'albums';
                $route_path = G\get_route_name();
                if(get_category()) {
                    $route_path .= '/' . get_category()['url_key'];
                }
                $tabs[$k]['url'] = G\get_base_url($route_path . '/?' . $tabs[$k]['params']);
            }
           
            if(!$current) {
                $tabs[0]['current'] = true;
            }
           
        ?>
       
        <?php G\Render\include_theme_file("snippets/tabs"); ?>
       
        <?php
            if(is_admin()) {
                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 G\Render\include_theme_file("snippets/listing_tools_editor"); ?>
        </div>
        <?php
            }
        ?>
       
    </div>
   
    <div id="content-listing-tabs" class="tabbed-listing">
        <div id="tabbed-content-group">
            <?php
                G\Render\include_theme_file("snippets/listing");
            ?>
        </div>
    </div>
   
</div>

<?php G\Render\include_theme_footer(); ?>

Create route.albums.php in app/routes/
Code:
<?php

/* --------------------------------------------------------------------

  Chevereto
  http://chevereto.com/

  @author    Rodolfo Berrios A. <http://rodolfoberrios.com/>
            <inbox@rodolfoberrios.com>

  Copyright (C) Rodolfo Berrios A. All rights reserved.
 
  BY USING THIS SOFTWARE YOU DECLARE TO ACCEPT THE CHEVERETO EULA
  http://chevereto.com/license

  --------------------------------------------------------------------- */

$route = function($handler) {
    try {
        if(!CHV\get_chv_setting('website_explore_page')) {
            return $handler->issue404();
        }
        $handler::$vars['pre_doctitle'] = _s('Albums');
        $handler::$vars['category'] = NULL;
       
        if($handler->isRequestLevel(2)) return $handler->issue404(); // Allow only 3 levels
       
    } catch(Exception $e) {
        G\exception_to_error($e);
    }
};


And bala try with https://likz.me/albums :D
 
Ok let rock :D

create albums.php in app/themes/Peafowl

Code:
<?php if(!defined('access') or !access) die('This file cannot be directly accessed.'); ?>
<?php G\Render\include_theme_header(); ?>

<?php CHV\Render\show_banner('explore_after_top'); ?>

<div class="content-width">
  
    <?php
      
        // Use CHV magic params
        $list_params = CHV\Listing::getParams();
      
        $type = 'albums';
      
        try {
                global $list;
                        $list = new CHV\Listing;
                        $list->setType($type); // images | users | albums
                        $list->setOffset($list_params['offset']);
                        $list->setLimit($list_params['limit']); // how many results?
                        $list->setItemsPerPage($list_params['items_per_page']); // must
                        $list->setSortType($list_params['sort'][0]); // date | size | views
                        $list->setSortOrder($list_params['sort'][1]); // asc | desc
                        $list->setRequester(CHV\Login::getUser());
                        $list->output_tpl = $type;
                        $list->exec();
        } catch(Exception $e) {
            G\exception_to_error($e);
        }
    ?>
  
    <div class="header header-tabs margin-bottom-10 follow-scroll">
        <h1><strong><?php echo get_category() ? get_category()['name'] : _s('Albums'); ?></strong></h1>
        <?php
            global $tabs; // Define it as a global to bind it on the included tab.php
            $tabs = array(
                0 => array(
                    '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,
                ),
                1 => array(
                    'list'        => true,
                    'tools'        => true,
                    'label'        => _s('Oldest'),
                    'id'        => 'list-most-oldest',
                    'params'    => 'list=albums&sort=date_asc&page=1',
                    'current'    => $_REQUEST['sort'] == 'date_asc',
                )
            );
          
            $current = false;
            foreach($tabs as $k => $v) {
              
                if(get_category()) {
                    $tabs[$k]['params_hidden'] .= 'category_id=' . get_category()['id'];
                }
              
                if($v['current']) {
                    $current = true;
                }
                $tabs[$k]['type'] = 'albums';
                $route_path = G\get_route_name();
                if(get_category()) {
                    $route_path .= '/' . get_category()['url_key'];
                }
                $tabs[$k]['url'] = G\get_base_url($route_path . '/?' . $tabs[$k]['params']);
            }
          
            if(!$current) {
                $tabs[0]['current'] = true;
            }
          
        ?>
      
        <?php G\Render\include_theme_file("snippets/tabs"); ?>
      
        <?php
            if(is_admin()) {
                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 G\Render\include_theme_file("snippets/listing_tools_editor"); ?>
        </div>
        <?php
            }
        ?>
      
    </div>
  
    <div id="content-listing-tabs" class="tabbed-listing">
        <div id="tabbed-content-group">
            <?php
                G\Render\include_theme_file("snippets/listing");
            ?>
        </div>
    </div>
  
</div>

<?php G\Render\include_theme_footer(); ?>

Create route.albums.php in app/routes/
Code:
<?php

/* --------------------------------------------------------------------

  Chevereto
  http://chevereto.com/

  @author    Rodolfo Berrios A. <http://rodolfoberrios.com/>
            <inbox@rodolfoberrios.com>

  Copyright (C) Rodolfo Berrios A. All rights reserved.

  BY USING THIS SOFTWARE YOU DECLARE TO ACCEPT THE CHEVERETO EULA
  http://chevereto.com/license

  --------------------------------------------------------------------- */

$route = function($handler) {
    try {
        if(!CHV\get_chv_setting('website_explore_page')) {
            return $handler->issue404();
        }
        $handler::$vars['pre_doctitle'] = _s('Albums');
        $handler::$vars['category'] = NULL;
      
        if($handler->isRequestLevel(2)) return $handler->issue404(); // Allow only 3 levels
      
    } catch(Exception $e) {
        G\exception_to_error($e);
    }
};


And bala try with https://likz.me/albums :D


Thanks :D

It works nice !!!!
 
I did as you said, but I opened a blank page

I create albums.php and route.albums.php

Or do we need something else to do?
 
Last edited:
Hi , sorry i forgot :D

try remove this in route.albums.php and test again

Code:
if(!CHV\get_chv_setting('website_explore_page')) {
            return $handler->issue404();
        }
 
Brilliantly !!!
That I did not suffer long, tell me how to insert a menu item next to the Explore Search Random (I think it is in the file Header.php ???)
 
Back
Top