Support ⇒ Explain Please ⇒ CSS/Main Menu entry for "My Gallery"? ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexExplain Please

CSS/Main Menu entry for "My Gallery"? Reply to topic


If there a way to add a "My Gallery" entry to the general CSS Menu in Admin > CPG Main Menu?

The one I know is of the form coppermine/cat=10002, so I'd need to know the user's userid number!

I wondered if there is another way around that?

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


We could modify coppermine to support "/coppermine/cat=mine" or similar.
I think that would be the easiest approach

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


Thanks DJ for the pointer.

Decided to use 9999 (that is FIRST_USER_CAT - 1) as there are no restrictions on coppermine category/album names, so 'mine' could be used as a valid name somewhere.

Changes were simple, finding where $cat needed to be adjusted was not! In particular the function get_pic_data reloads $cat from $_GET['cat'], and so was resetting $cat!!! I'm not sure if that line of code is even required, but as I have limited knowledge of testing coppermine I left it be and just added my hack after it as well.

Developed and tested under 9.2.1CSV, but suspect valid for all recent DF versions.

Here are the 3 changes.
In includes/coppermine/init.inc find (around line 23):
define('USER_GAL_CAT', 1); define('FIRST_USER_CAT', 10000);
and change to:
define('USER_GAL_CAT', 1); define('MY_USER_CAT', 9999); define('FIRST_USER_CAT', 10000);

In modules/coppermine/include/load.inc find (around line 112):
else if (is_numeric($cat) && $cat > 0) { if ($cat > FIRST_USER_CAT) {
and change to:
else if (is_numeric($cat) && $cat > 0) { if ($cat == MY_USER_CAT) {$cat = FIRST_USER_CAT + USER_ID;} // layingback - my gallery mod if ($cat > FIRST_USER_CAT) {

In includes/coppermine/functions.inc find (around line 383) in the get_pic_data function:
$cat = (isset($_GET['cat']) && is_numeric($_GET['cat'])) ? $_GET['cat'] : 0;
and change to:
$cat = (isset($_GET['cat']) && is_numeric($_GET['cat'])) ? $_GET['cat'] : 0; if ($cat == MY_USER_CAT) { // layingback - my gallery mod $cat = FIRST_USER_CAT + USER_ID; }

Thanks again for the help.

EDIT: To fix typo ( = -> == Rolling Eyes )

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Nice, what is the link to add to the menu?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


Sorry!

coppermine&cat=9999

To remind yourself again in the future, look to the My gallery link in your Galleries Tasks menu, eg. coppermine&cat=10002 for the Admin, and substitute 9999 - or whatever you chose to use in the define('MY_USER_CAT', 9999); line.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


If I'm not mistaken this will work with one user only, not dynamic for each user.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Try code.google.com/p/drag...mp;name=v9
and just use coppermine/cat=mine for links

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


NanoCaiordo wrote
If I'm not mistaken this will work with one user only, not dynamic for each user.

Not sure why you should think that. I have 3 accounts on my dev system and it works there. (Am in process of getting confirmation from my live site ...) But my code is essentially the same, except that I don't need to add a global, and I follow the literal naming convention of coppermine which means you can use whatever code you like for the mine/999 by editing the define in init.inc. (Using 'mine' will prevent access to a category named mine should it exist ...)

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Hi Layingback,

define('MY_USER_CAT', 'mine'); can indeed be done as well.
But then it is not like the literal naming convention of coppermine as the defines are numeric.

Nano his global variable is also not the best solution as you point.

Neither is bad and it shows that there is more then 1 solution to a problem.

After some discussion i even came up with a simplification to nano and your code combined.

/includes/coppermine/init.inc
$cat = isset($_POST['cat']) ? $_POST['cat'] : isset($_GET['cat']) ? $_GET['cat'] : 0; if (!is_numeric($cat)) $cat = 'mine' === $cat ? USER_ID + FIRST_USER_CAT : null;


/includes/coppermine/functions.inc
$cat = isset($_GET['cat']) && $_GET['cat'] : 0; if (!is_numeric($cat)) $cat = 'mine' === $cat ? USER_ID + FIRST_USER_CAT : 0;

This doesn't use a global nor your define and makes it hardcoded.
This is arguable as well if you want that or not but, then it would be nicer to be configurable through Admin -> Coppermine configuration screen.

So to me you both have a valid solution that solves your problem and i love to see the discussion of several minds to solve it Smile

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


P.S. phpBB uses the word "egosearch" to find all your posts.
Coppermine could instead also have something like /coppermine/cat=0/meta=egosearch/ to all your posted images.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial

Last edited by DJ Maze on Fri Dec 14, 2012 3:08 am; edited 1 time in total


After revising the code we could just have one single modification without the worry of breacking anything.

includes/coppermine/init.inc
$cat = isset($_POST['cat']) ? $_POST['cat'] : isset($_GET['cat']) ? $_GET['cat'] : 0; if (!is_numeric($cat)) $cat = $_GET['cat'] = 'mine' === $cat ? USER_ID + FIRST_USER_CAT : null;

Can use MY_USER_CAT instead of "mine" or not.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


What happens if the user doesn't have a gallery?

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0


Kinsman wrote
What happens if the user doesn't have a gallery?

You get the first 2 lines of the coppermine menu, and then a blank area. At least with my version, can't speck to the other versions but presume results would be similar.

I thought about adding a message, but then there's the issue of language translation (there were no suitable messages that I found in main.php or coppermine) so left as is. Tested it out on PENTAXdslr.eu, which is truly multi-lingual with postings in > 1 language plus Google Translate for additional languages (all done in reDeisgn3+) and users felt comfortable with it as it was, so I think it's OK.

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Current one produce the same results as when you click "My Gallery" from coppermine's custom block or from Your_Account custom block.

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


NanoCaiordo wrote
After revising the code we could just have one single modification without the worry of breacking anything.

includes/coppermine/init.inc
$cat = isset($_POST['cat']) ? $_POST['cat'] : isset($_GET['cat']) ? $_GET['cat'] : 0; if (!is_numeric($cat)) $cat = $_GET['cat'] = 'mine' === $cat ? USER_ID + FIRST_USER_CAT : null;

Can use MY_USER_CAT instead of "mine" or not.


This works great, link to add for this is "getlink".

coppermine&cat=mine

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
2.6.18-164.11.1.el5xen/2.2.13/5.0.89-community-log/5.2.11/9.3.3.0

All times are UTC


Jump to: