forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 themes (visuals) => Topic started by: allvip on October 09, 2013, 04:23:11 am

Title: Custom Sidebar only on the homepage
Post by: allvip 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.
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré 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.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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.
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré 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 (http://forum.coppermine-gallery.net/index.php/topic,76722.msg370584.html#msg370584)]
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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.
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré 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.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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;
}
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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;
}
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré 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}">
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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.
Title: Re: Custom Sidebar only on the homepage
Post by: Niecher 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
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 09, 2013, 06:55:39 pm
please help me understant where should I place {CPG_MAIN_BLOCK_OUTER_STYLE}
Title: Re: Custom Sidebar only on the homepage
Post by: Niecher 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.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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;
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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;

Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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
Title: Re: Custom Sidebar only on the homepage
Post by: Niecher 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.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip 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;   
}
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 09, 2013, 09:08:52 pm
thanks a lot Niecher for the class ideea
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 09, 2013, 09:11:41 pm
I never would of thing to replace style="{CPG_MAIN_BLOCK_OUTER_STYLE} from Andre code with class="cpg_main_block_outer_style"
I'm so happy and greatfull for your help

thank youuuuuuuuuuu
was very important for my new theme
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré on October 10, 2013, 10:34:07 am
I don't understand what you did, respectively why you did it that way. Your solution will return
Code: [Select]
    <div id="cpg_main_block_outer" class="cpg_main_block_outer_style">
    <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>
on index.php. As you can see, you now have 2 cpg_main_block_outer blocks and I assume, only one of them get closed.


My idea was to use inline CSS instead of a new class and an additional div block. I.e. the token in
Code: [Select]
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">will be replaced the following way:
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}'] = 'width: 60%';
    } else {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = '';
    }

I recommend to use that solution to get valid HTML code.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 10, 2013, 01:44:36 pm
I think I don't understand where to put the code:

replace in template.html:

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>

with:

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

and add under 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['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = 'width: 60%';
    } else {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = '';
    }
every time I delete:
[code]
<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>
I get the result from the attachment.
[/code]
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré on October 10, 2013, 01:50:49 pm
Please try to comprehend how this mod is supposed to work before randomly applying or replacing anything.

Here again the complete mod, expecting an unmodified gallery:

Open your theme's template.html file, find
Code: [Select]
<div id="cpg_main_block_outer">(just this line!) and replace with
Code: [Select]
<div id="cpg_main_block_outer" style="{CPG_MAIN_BLOCK_OUTER_STYLE}">
Now, open your theme's theme.php file and add the following code to the pageheader function:
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}'] = 'width: 60%';
    } else {
        $template_vars['{CPG_MAIN_BLOCK_OUTER_STYLE}'] = '';
    }
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 10, 2013, 01:55:39 pm
ok.it works perfect.thans a looooooooooooot.
boy I such and idiot
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 10, 2013, 01:57:41 pm
 boy I am such an idiot
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 10, 2013, 02:10:47 pm
please delete all my 2 pages post
how will want to use your code will have to read 2 pages of wrong posts
Title: Re: Custom Sidebar only on the homepage
Post by: Αndré on October 10, 2013, 02:15:47 pm
I just added a link to the solution to my second reply.
Title: Re: Custom Sidebar only on the homepage
Post by: allvip on October 10, 2013, 02:21:11 pm
great.thanks