Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Wrapp every subcategories in diffrent divs (dinamyc id for the body )  (Read 3702 times)

0 Members and 1 Guest are viewing this topic.

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342

I want to wrapp every subcategory with all subpages in his own div (menu and header included if is possible-the wrapper to start after the body tag):

Aaliyah Dana with all pages (Aaliyah Dana albums list,Photoshoot album thumbnalis,RC MTV Movie Awards 2001 album thumbnalis,Adam Sandler albums list,Just Go with it 2011 on the set stills album thumbnalis) to be wrapped in div class listA1

Adam Sandler with all pages (Adam Sandler  albums list and  albums thumbnalis) to be wrapped in div class listA2

Backstreet Boys with all pages (Backstreet Boys  albums list and  albums thumbnalis) to be wrapped in div class listB1

Aaliyah Dana Subcategory
http://allvip.us/gallery/index.php?cat=13

Adam Sandler Subcategory
http://allvip.us/gallery/index.php?cat=14

Backstreet Boys Subcategory
http://allvip.us/gallery/index.php?cat=40
« Last Edit: July 13, 2014, 05:31:24 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342
Re: Wrapp every subcategories in diffrent divs
« Reply #1 on: February 21, 2014, 06:39:12 am »

meta albums are not important but wood be nice to be included if possible.
displayimage.php not included

« Last Edit: February 21, 2014, 04:13:05 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342
Re: Wrapp every subcategories in diffrent divs
« Reply #2 on: February 21, 2014, 04:12:31 pm »

SOLUTION 1 - dinamyc id for the body tag for every category and all the pages in it

cat=1 and all the albums and pages in it will have id page1, cat=2 and all the albums and pages in it will have id page2.

With firefox inspect element,firebug or view page source is possible to see the body id <body id="page1"> after using the code.

Then you can add specific rules in the .css file of your theme like this:

Code: [Select]
body#page1{background:red;}
body#page2{background:black;}
body#page1 #main_menu{color:red;font-family:Verdana,sans-serif;}

REPLACE custom text in the code like themes/your_theme_nam... with the right path.

Step 1 

Open themes/your_theme_name/theme.php and add this code to function pageheader before $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars); (copy the function pageheader from themes/sample/theme.php if is not in your theme.php) :

CODE edited 15/12/2016. The old code was wrong.

Code: [Select]
    // css mod - start
    global $cat;
    $superCage = Inspekt::makeSuperCage();

    if ($superCage->get->getRaw('file') == 'minicms/cms') {
        $current_id = $superCage->get->getInt('id');
    } elseif (!$cat) {
        $current_id = 0;
    } elseif ($cat < 0) {
        $aid = -$cat;
        $current_id = mysql_result(cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$aid' LIMIT 1"), 0);
    } else {
        $current_id = $cat;
    }

   

    $bodyid = $current_id;
    $template_vars['{BODYID}'] = $bodyid;
    // css mod - end

Step 2

Open themes/your_theme_name/template.html

FIND

Code: [Select]
<body>

REPLACE WITH

Code: [Select]
<body id="page{BODYID}">

SOLUTION 2 - dinamyc id for the body tag for every category and every album

cat=1 will have body id pagecat_1 and album=1 with all the pages in it will have id pagealb_1, cat=2 will have body id pagecat_2 and album=2 with all the pages in it will have id pagealb_2 etc

Just replace the code from step 1 of solution 2 with this code:

Code: [Select]
    // css mod - start
        global $cat, $CPG_PHP_SELF;

    if ($cat < 0) {
        $what = 'alb_';
        $current_id = -$cat;
    } else {
        $what = 'cat_';
        $current_id = $cat;
    }
    $bodyid = $what.$current_id;
    $template_vars['{BODYID}'] = $bodyid;
   
    // css mod - end
« Last Edit: December 15, 2016, 02:07:02 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342
Re: Wrapp every subcategories in diffrent divs
« Reply #3 on: February 21, 2014, 04:32:50 pm »

SOLUTION 3 - diffrent style sheet for each category and all the pages in it
Solution 1 is better.  Multiple style sheets will make the gallery load slower. This solution is better only if you need the pages to be very, very diffrent.

REPLACE custom text in the code like themes/your_theme_name/your_css_file.css with the right path.

Step 1

Create a folder named css in themes/your_theme_name and upload your css files in it: style_1.css, style_2.css etc. cat=1 will have style_1,cat=2 will have style_2 etc

Step 2

Open themes/your_theme_name/theme.php and add this code to function pageheader before $template_vars = CPGPluginAPI::filter('theme_pageheader_params', $template_vars); (copy the function pageheader from themes/sample/theme.php if is not in your theme.php) :

CODE edited 15/12/2016. The old code was wrong.

Code: [Select]
    // css mod - start
    global $cat;
    $superCage = Inspekt::makeSuperCage();

    if ($superCage->get->getRaw('file') == 'minicms/cms') {
        $current_id = $superCage->get->getInt('id');
    } elseif (!$cat) {
        $current_id = 0;
    } elseif ($cat < 0) {
        $aid = -$cat;
        $current_id = mysql_result(cpg_db_query("SELECT category FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid = '$aid' LIMIT 1"), 0);
    } else {
        $current_id = $cat;
    }

   

    If (!empty($cat)) {
    $cssfile = "<link rel=\"stylesheet\" href=\"themes/your_theme_name/style_{$current_id}.css\" type=\"text/css\" />";
} else {$cssfile = "<link rel=\"stylesheet\" href=\"themes/your_theme_name/your_main_css_file.css\" type=\"text/css\" />";}
    $template_vars['{CSSFILE}'] = $cssfile;
    // css mod - end

Step 3

Open themes/your_theme_name/template.html

FIND

Code: [Select]
<link rel="stylesheet" href="themes/your_theme_name/your_css_file.css" type="text/css" />

REPLACE WITH:

Code: [Select]
{CSSFILE}

SOLUTION 4 - diffrent style sheet for every category and every album.

Step 1

Same as solution 3 step 1 but diffrent names for the css files like this:

cat=1 will take from the css folder style_cat_1.css and album=1 with all the pages in it will have style_alb_1.css, cat=2 will have style_cat_2.css and album=2 with all the pages in it will have style_alb_1.css etc

Step 2

Just replace step 2 from solution 3 with this code

Code: [Select]
    // css mod - start
        global $cat, $CPG_PHP_SELF;

    if ($cat < 0) {
        $what = 'alb_';
        $current_id = -$cat;
    } else {
        $what = 'cat_';
        $current_id = $cat;
    }

   
 If (!empty($cat)) {
    $cssfile = "<link rel=\"stylesheet\" href=\"themes/your_theme_name/style_{$what}{$current_id}.css\" type=\"text/css\" />";
} else {$cssfile = "<link rel=\"stylesheet\" href=\"themes/your_theme_name/your_main_css_file.css\" type=\"text/css\" />";}
    $template_vars['{CSSFILE}'] = $cssfile;
    // css mod - end
« Last Edit: December 15, 2016, 02:20:47 pm by allvip »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342
Re: Wrapp every subcategories in diffrent divs
« Reply #4 on: February 21, 2014, 04:37:06 pm »

Solutions based on Andre's code from here reply#9:

http://forum.coppermine-gallery.net/index.php/topic,76924.0.html
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1342
Re: Wrapp every subcategories in diffrent divs
« Reply #5 on: February 21, 2014, 04:39:48 pm »

How can I exclude displayimage.php ( I want displayimage.php to have no id for the body tag)
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15761
Re: Wrapp every subcategories in diffrent divs
« Reply #6 on: February 28, 2014, 12:31:44 pm »

How can I exclude displayimage.php

Wrap your echo in something like
Code: [Select]
global $CPG_PHP_SELF;
if ($CPG_PHP_SELF != 'displayimage.php') {
    // echo solution 1 or 2
}
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.