Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1] 2   Go Down

Author Topic: Custom Sidebar only on the homepage  (Read 8051 times)

0 Members and 1 Guest are viewing this topic.

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Custom Sidebar only on the homepage
« on: October 09, 2013, 04:23:11 am »

I know that I have to creat a new div and place it in theme.php under sidebar or page footer function to show only on the index page but I gived width: 60%; float: left; to #cpg_main_block_outer and width: 40%; float: right; to my new sidebar div.

the problem now is #cpg_main_block_outer (gallery main div with categories and albums) is 60% on every page.

I think I'm using the wrong way.
Is there a way to have a custom sidebar only on the index.php page?

I know I ask a lot a questions but I'm creating a theme VERY FANCY and VERY DIFFRENT from a coppermine theme.
I will post it for free download on the forum.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Sidebar only on the homepage
« Reply #1 on: October 09, 2013, 09:04:56 am »

I assume you currently added the new div block to the template.html file? If so, replace it completely with a new custom token like {MY_NEW_DIV}. Now we're able to replace that token with the help of the function pageheader.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #2 on: October 09, 2013, 03:52:02 pm »

yes I know that but #cpg_main_block_outer is 60% on every page.

how can I make him show 60% width on the index page and 100% width on all other pages?
 without width: 60%; float: left; or just float: left; for #cpg_main_block_outer the sidebar is showing above the div not to the left.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Sidebar only on the homepage
« Reply #3 on: October 09, 2013, 04:18:27 pm »

Instead of hard-coding the width you also need to use a token.

[Edit: Final solution can be found here]
« Last Edit: October 10, 2013, 02:15:17 pm by Αndré »
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #4 on: October 09, 2013, 04:52:16 pm »

to put #cpg_main_block_outer  in theme.php too?
token for width?
please help
that will break all other pages.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Sidebar only on the homepage
« Reply #5 on: October 09, 2013, 04:58:59 pm »

I don't know where exactly you added your CSS code. Either please describe it more detailed or attach your theme to your next reply.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #6 on: October 09, 2013, 05:11:25 pm »

is the curve theme that I edit.
I just added to function pageheader in theme.php:

Code: [Select]
global $CPG_PHP_SELF;
    $superCage = Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && !count($superCage->get->_source)) {
        $template_vars['{MY_NEW_DIV}'] = <<< EOT
  <div id="divS">
   
  </div>
EOT;
    } else {
        $template_vars['{MY_NEW_DIV}'] = '';
    }

and {MY_NEW_DIV} before:

Code: [Select]
<div id="cpg_main_block_outer">
        <div class="cpg_main_block_inner">
            {GALLERY}
            <br /> <!-- workaround for issue 64492 - do not remove the line break! -->
        </div>
    </div>

and this to style.css

Code: [Select]
#divS {
margin: 0px;
padding: 0px;
color: #000000;
        background-color: #cccccc;
        float: right;
        width: 40%;
        height: 450px;
        background-image: url(../image/ad.jpg);
        background-repeat: no-repeat;
}

and curve theme has #cpg_header_block_outer style for the gallery div:

Code: [Select]
#cpg_header_block_outer  {
    background-color: #fefefe;
    background-image: none;
    background-repeat: no-repeat;
    background-attachment: scroll;
    background-position: 0pt -633px;
    padding-left: 20px;
}
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #7 on: October 09, 2013, 05:14:28 pm »

style for #cpg_header_block_outer with width and and float adeed:

Code: [Select]
#cpg_header_block_outer  {
    background-color: #fefefe;
    background-image: none;
    background-repeat: no-repeat;
    background-attachment: scroll;
    background-position: 0pt -633px;
    padding-left: 20px;
    width: 60%;
    float: left;
}
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Custom Sidebar only on the homepage
« Reply #8 on: October 09, 2013, 05:17:50 pm »

As I said: remove the hard-coded width: 60%; from cpg_header_block_outer. Instead, add a new token to template.html and replace it in theme.php, like
Code: [Select]
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #9 on: October 09, 2013, 05:56:26 pm »

soory but I dont understand much.
I added the code: in function pageheader under :

Code: [Select]
global $CPG_PHP_SELF;
    $superCage = Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && !count($superCage->get->_source)) {
        $template_vars['{MY_NEW_DIV}'] = <<< EOT
  <div id="divS">
   
  </div>
EOT;
    } else {
        $template_vars['{MY_NEW_DIV}'] = '';
    }

but: Parse error: syntax error, unexpected '<' in /home/allvip/public_html/allvip.us/cpgz/themes/zimbio/theme.php on line 1158

with:

Code: [Select]
global $CPG_PHP_SELF;
    $superCage = Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && !count($superCage->get->_source)) {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = <<< EOT
  <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
EOT;
    } else {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = '';
    }

and {CPG_MAIN_BLOCK_OUTER_STYLE} before:

Code: [Select]
<div id="cpg_main_block_outer">
        <div class="cpg_main_block_inner">
            {GALLERY}
            <br /> <!-- workaround for issue 64492 - do not remove the line break! -->
        </div>
    </div>

and a new style in style.css:

Code: [Select]
#cpg_header_block_outer_style  {
    background-color: #fefefe;
    background-image: none;
    background-repeat: no-repeat;
    background-attachment: scroll;
    background-position: 0pt -633px;
    padding-left: 20px;
    width: 60%;
    float: left;
}

and nothing happens.
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: Custom Sidebar only on the homepage
« Reply #10 on: October 09, 2013, 06:37:43 pm »

you got that error because the template output, you put this:

Code: [Select]
<div id= {CPG_MAIN_BLOCK_OUTER_STYLE}>
when it replaced the token, you get this:

Code: [Select]
<div id = <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">>
Regards
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #11 on: October 09, 2013, 06:55:39 pm »

please help me understant where should I place {CPG_MAIN_BLOCK_OUTER_STYLE}
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: Custom Sidebar only on the homepage
« Reply #12 on: October 09, 2013, 07:21:42 pm »

to avoid the error in the output template, place it so
Code: [Select]
{CPG_MAIN_BLOCK_OUTER_STYLE}
when the token is replaced, it will show this:
Code: [Select]
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
since this is what you want for
Code: [Select]
$template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = <<< EOT
  <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
EOT;


Regards.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #13 on: October 09, 2013, 07:31:31 pm »

ok
added in template.html:

Code: [Select]
{CPG_MAIN_BLOCK_OUTER_STYLE}

before:

Code: [Select]
<div id="cpg_main_block_outer">
       <div class="cpg_main_block_inner">
            {GALLERY}
            <br /> <!-- workaround for issue 64492 - do not remove the line break! -->
        </div>
    </div>

and in theme.php just:

Code: [Select]
$template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = <<< EOT
  <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
EOT;

and in style css:

Code: [Select]
#cpg_main_block_outer  {
    background-color: #ffffff;
    background-image: url(images/frame_repeat.png);
    background-repeat: repeat-y;
    background-attachment: scroll;
    background-position: left top;
    padding-left: 0px;   
}
.cpg_main_block_outer_style  {
    background-color: #000000;
    background-image: url(images/frame_repeat.png);
    background-repeat: repeat-y;
    background-attachment: scroll;
    background-position: left top;
    padding-left: 0px;
    width: 60%;
    float: left;   
}

but nothing happens
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #14 on: October 09, 2013, 07:33:29 pm »

the main gallery block does not takes the style .cpg_main_block_outer_style that has width: 60%;
    float: left;
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #15 on: October 09, 2013, 08:15:36 pm »

the only changes in pageheader function is that I adeed:

Code: [Select]
$template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = <<< EOT
  <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
EOT;

Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #16 on: October 09, 2013, 08:19:28 pm »

{CPG_MAIN_BLOCK_OUTER_STYLE} is token to apply a new style to div cpg_main_block_outer
right?
so I create a new style in style.css .cpg_main_block_outer_style with the same name like the token and width: 60%; float: left;

but nothing
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: Custom Sidebar only on the homepage
« Reply #17 on: October 09, 2013, 08:41:49 pm »

Now I'm out and I can not see pageheader function, I can only write in the forum.

To see the style you added in your CSS, you need this:

<div id="cpg_main_block_outer" class="cpg_main_block_outer_style">

Regards.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #18 on: October 09, 2013, 08:58:05 pm »

thank you,thank you...than you

andre code was goog but not perfect  :)

Code: [Select]
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">

need to be

Code: [Select]
<div id="cpg_main_block_outer" class="cpg_main_block_outer_style">

now the main block is 100% on the index page and 60% flot to the left on all other pages.
Logged

allvip

  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Posts: 1362
Re: Custom Sidebar only on the homepage
« Reply #19 on: October 09, 2013, 09:06:35 pm »

step by step to have  Custom Sidebar only on the homepage:

1.add to theme.php under pageheader function (if you do not have it in ypur theme.php copy the function from themes/sample/theme.php:

Code: [Select]
global $CPG_PHP_SELF;
    $superCage = Inspekt::makeSuperCage();
    if ($CPG_PHP_SELF == 'index.php' && !count($superCage->get->_source)) {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = <<< EOT
      <div id="cpg_main_block_outer" class="cpg_main_block_outer_style">

EOT;
    } else {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = '';
    }

2. add to template.html:
Code: [Select]
{CPG_MAIN_BLOCK_OUTER_STYLE}

before:

Code: [Select]
<div id="cpg_main_block_outer" >
        <div class="cpg_main_block_inner">
            {GALLERY}
            <br /> <!-- workaround for issue 64492 - do not remove the line break! -->
        </div>
    </div>

3.add to style.css or whatever the name of your css file is:

Code: [Select]
   .cpg_main_block_outer_style  { 
    width: 60%;
    float: left;   
}
Logged
Pages: [1] 2   Go Up
 

Page created in 0.044 seconds with 20 queries.