coppermine-gallery.com/forum

Support => cpg1.6.x Support => cpg1.6 miscellaneous => Topic started by: findingcolors on December 24, 2025, 08:51:20 PM

Title: Custom Page(s) In Folders?
Post by: findingcolors on December 24, 2025, 08:51:20 PM
I was wondering if there's a way to put custom pages in folders? I know how to make a custom page and upload it to the main branch (example: yourwebsite.com/gallery/page.php)

but for organization purposes, is there a way to put these pages in folders and still have them display properly? For example, If I make a folder (named "pages") that has 3 custom pages, I would like the url to be: yourwebsite.com/gallery/pages/custom-page.php.

I tried and the pages don't show.
Title: Re: Custom Page(s) In Folders?
Post by: 406man on December 27, 2025, 05:36:16 PM
There's a way you can implement it which I won't claim is particularly clean or clever but it works.

Here's an example with a page called  page-abc.php  which uses the PHP require statement to call  page-xyz.php  in sub directory /sub  which is directly beneath the main coppermine directory

Here is the code for the two scripts, being sure to include a security check:

<?php
/***   page-abc.php   ***/

define('IN_COPPERMINE'true);

define('INDEX_PHP'true);
define('RESTRICTED_PRIV'true);

require(
'include/init.inc.php');

include 
'./sub/page-xyz.php';

?>



<?php
/***   page-xyz.php   ***/

if (!defined('IN_COPPERMINE')) {
    die(
'Not in Coppermine...');
}
echo 
'This is the sub page';


?>

Once page-abc.php has been created you don't need to touch it again and you can just update page-xyz.php
Title: Re: Custom Page(s) In Folders?
Post by: findingcolors on December 27, 2025, 07:25:44 PM
Quote from: 406man on December 27, 2025, 05:36:16 PMThere's a way you can implement it which I won't claim is particularly clean or clever but it works.

Here's an example with a page called  page-abc.php  which uses the PHP require statement to call  page-xyz.php  in sub directory /sub  which is directly beneath the main coppermine directory

Here is the code for the two scripts, being sure to include a security check:

<?php
/***   page-abc.php   ***/

define('IN_COPPERMINE'true);

define('INDEX_PHP'true);
define('RESTRICTED_PRIV'true);

require(
'include/init.inc.php');

include 
'./sub/page-xyz.php';

?>



<?php
/***   page-xyz.php   ***/

if (!defined('IN_COPPERMINE')) {
    die(
'Not in Coppermine...');
}
echo 
'This is the sub page';


?>

Once page-abc.php has been created you don't need to touch it again and you can just update page-xyz.php


This still kind of defeats the purpose. I want all of my pages in mygallery.com/pages/page-title.php and use the /sub url in the url bar, with no duplicate pages in the main folder, and take the style of my coppermine theme.
Title: Re: Custom Page(s) In Folders?
Post by: Joe Carver on December 28, 2025, 06:22:09 PM
With the folder and pages inside located in your Coppermine folder, try this as a link to the pages:

Your_Coppermine . com/index.php?file=your_custom_folder/custom_page.php
I cannot test/verify success here, and am not sure about how .css, etc., will behave.