Custom Sidebar only on the homepage Custom Sidebar only on the homepage
 

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

Main Menu

Custom Sidebar only on the homepage

Started by allvip, October 09, 2013, 04:23:11 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

allvip

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.

Αndré

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.

allvip

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.

Αndré

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

[Edit: Final solution can be found here]

allvip

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

Αndré

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.

allvip

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


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:


<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


#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:


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

allvip

style for #cpg_header_block_outer with width and and float adeed:


#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;
}

Αndré

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
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">

allvip

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


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:


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:


<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:


#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.

Niecher

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

<div id= {CPG_MAIN_BLOCK_OUTER_STYLE}>

when it replaced the token, you get this:

<div id = <div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">>

Regards

allvip

please help me understant where should I place {CPG_MAIN_BLOCK_OUTER_STYLE}

Niecher

to avoid the error in the output template, place it so
{CPG_MAIN_BLOCK_OUTER_STYLE}

when the token is replaced, it will show this:
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">

since this is what you want for

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



Regards.

allvip

ok
added in template.html:


{CPG_MAIN_BLOCK_OUTER_STYLE}


before:


<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:


$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:


#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

allvip

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

allvip

the only changes in pageheader function is that I adeed:


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


allvip

{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

Niecher

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.

allvip

thank you,thank you...than you

andre code was goog but not perfect  :)


<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">


need to be


<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.

allvip

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:


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:

{CPG_MAIN_BLOCK_OUTER_STYLE}


before:


<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:


   .cpg_main_block_outer_style  { 
    width: 60%;
    float: left;   
}