Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to add a new box class?


lindsayanng

Recommended Posts

Posted

The knowledge base used to have this awesome article on how to add a new box class to your info boxes and I used to refer to it all the time and now, since the structure upgrade, the knowledge base is missing a LOT of this type of information!!

 

So does anyone have a copy of this article?? Or can someone give me a quick tip on how to do this??

 

Again, its one of those things I have done before but have always used the cheat sheet to get it done.

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Does this look familar???

 

The class for the boxes can be change for one box only by adding a new box class with a

new style and changing that particular box to the new style.

Create a new "box class" in catalog/includes/classes/boxes.php ... the one created below

uses plainBox as the new box class:

class plainBox extends tableBox {

function plainBox($contents) {

$this->table_data_parameters = 'class="plainBox"';

$this->tableBox($contents, true);

}

}

In the stylesheet.css, define a new class called "plainBox" and assign the

settings you want for your new box style.

Change your catalog/includes/boxes/file (using the manufacturers box as an example) so

that the last line reads:

From this:

new infoBox($info_box_contents);

?>

< /td>

< /tr>

< !-- manufacturers_eof //-->

To this:

new plainBox($info_box_contents);

?>

< /td>

< /tr>

< !-- manufacturers_eof //-->

Sometimes you have to alter this code also at the top of the box file. Just do this if the

above doesn't work.

new infoBoxHeading

To:

new plainBox

The new products box is changed in the includes/modules/new_products.php page.

Posted

www.clubosc.com/how-to-make-just-1-infobox-a-different-style.html

 

No need to change the box class file.

Posted

thanks soo much guys!!! BryceJr - how in the world did you find the old documents?? I ended up on a weird knowledge base with little info on it.

 

Burt - i will check out your solution as well.. thanks again!

 

LOVE YOU ALL!

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Oscommerce Knowledge Base (Articles in 'Boxes') moved >> here

Thanks for that link Bryce. :D

 

All I had was the pdf format of the knowledge base.

Posted

thanks again guys for the links.. unfortunately because I have the CSS addon, even that code isn't working. I need to learn a little more about how the box classes work and what they do. Oh well, i will figure it out.. and this stuff will definitely help me.

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

thanks again guys for the links.. unfortunately because I have the CSS addon, even that code isn't working. I need to learn a little more about how the box classes work and what they do. Oh well, i will figure it out.. and this stuff will definitely help me.

Lindsay what is that css addon you have?

 

Using Burt's method should work even with that addon. Did you refresh your browser to make sure you refreshed the stylesheet?

Posted

I have the addon that removes all of the styles.. so while burt's method would work, it was hard to find exactly where to change / add a specific style.. that was the issue. The code is entirely mucked from the base osc install.

 

Either way, it i did get figure it out by copying the old class and pasting it with a new name and then editing it.

 

I never really was able to build my own classes though from scratch.. stupid class box system!!!!

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Either way, it i did get figure it out by copying the old class and pasting it with a new name and then editing it.

Glad you got it.

 

I never really was able to build my own classes though from scratch.. stupid class box system!!!!

Tell me about it. I'm still trying to learn them too.

Posted

here's a question.. why do they even have the box class creator? Couldn't you just add a class to the table (like in burt's suggestion)?? I mean, to build a basic CSS class from php seems a little wild to me. I am thinking I can probably remove the classes/boxes.php file and all references to the class and replace them with a simple <div id=#classname"> and we can work much much more easily

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

here's a question.. why do they even have the box class creator? Couldn't you just add a class to the table (like in burt's suggestion)?? I mean, to build a basic CSS class from php seems a little wild to me. I am thinking I can probably remove the classes/boxes.php file and all references to the class and replace them with a simple <div id=#classname"> and we can work much much more easily

 

 

Hi

 

 

class SideinfoBoxHeading extends tableBox {

function SideinfoBoxHeading($contents,

$left_corner = true, $right_corner = true,

$right_arrow = false) {

$this->table_cellpadding = '0';

$left_corner = tep_image(DIR_WS_IMAGES .

'infobox/corner_left.gif');

if ($right_arrow == true) {

$right_arrow = '<a class="infoboxheadinglink"

href="' . $right_arrow . '">' . $contents[0]

['text'] . ' »</a>';

} else {

$right_arrow = $contents[0]['text'];

}

$right_corner = tep_image(DIR_WS_IMAGES .

'infobox/corner_right.gif');

$info_box_contents = array();

$info_box_contents[] = array('params' =>

'width="100%" class="SideinfoBoxHeading"',

'text' =>

$right_arrow);

$this->tableBox($info_box_contents, true);

}

}

 

class SideinfoBox extends tableBox {

function SideinfoBox($contents) {

$info_box_contents = array();

$info_box_contents[] = array('text' => $this->SideinfoBoxContents($contents));

$this->table_cellpadding = '0';

$this->table_parameters =

'class="SideinfoBox"';

$this->tableBox($info_box_contents, true);

}

function SideinfoBoxContents($contents) {

$this->table_cellpadding = '0';

$this->table_parameters = 'class="SideinfoBoxContents"';

$info_box_contents = array();

$info_box_contents[] = array(array('text' =>

tep_draw_separator('pixel_trans.gif', '100%', '1')));

for ($i=0, $n=sizeof($contents); $i<$n; $i++) {

$info_box_contents[] = array(array('align' =>(isset($contents[$i]['align']) ? $contents[$i]['align'] : ''),

'form' =>(isset($contents[$i]['form']) ? $contents[$i]['form']: ''),

'params'=> 'class="boxText"',

'text' =>(isset($contents[$i]['text']) ? $contents[$i]['text']: '')));

}

$info_box_contents[] = array(array('text' =>

tep_draw_separator('pixel_trans.gif', '100%', '1')));

return $this->tableBox($info_box_contents);

}

}

To improve is to change; to be perfect is to change often.

 

Posted

Umm what the heck is this?? your "answer" isn't really making sense at all

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Umm what the heck is this?? your "answer" isn't really making sense at all

Just one for the headings and one for the content

To improve is to change; to be perfect is to change often.

 

Posted

hmm yea. STill not making sense at all.. thanks though

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Just one for the headings and one for the content

 

Hi took it from something I found underway...

do not know if it is relevant but definitely a nice bit of information for anybody reading!!!!

 

 

Recoding the InfoBoxes

Let's start changing some code to allow us to give the side InfoBoxes some

style! The problem here is that we need to make our “side” InfoBoxes

differently to our other InfoBoxes (eg “New Products for...” box).

This is pretty easy :), all you need to do is open up: /includes/classes/boxes.php

And add the following code at the very end of the file before the ?> tag:

class SideinfoBoxHeading extends tableBox {

function SideinfoBoxHeading($contents,

$left_corner = true, $right_corner = true,

$right_arrow = false) {

$this->table_cellpadding = '0';

$left_corner = tep_image(DIR_WS_IMAGES .

'infobox/corner_left.gif');

if ($right_arrow == true) {

$right_arrow = '<a class="infoboxheadinglink"

href="' . $right_arrow . '">' . $contents[0]

['text'] . ' »</a>';

} else {

$right_arrow = $contents[0]['text'];

}

$right_corner = tep_image(DIR_WS_IMAGES .

'infobox/corner_right.gif');

$info_box_contents = array();

$info_box_contents[] = array('params' =>

'width="100%" class="SideinfoBoxHeading"',

'text' =>

$right_arrow);

$this->tableBox($info_box_contents, true);

}

}

Save the file.

Page 15

Now add the following code to the exact same file, again making sure you add

it directly before the final ?> tag:

class SideinfoBox extends tableBox {

function SideinfoBox($contents) {

$info_box_contents = array();

$info_box_contents[] = array('text' => $this-

>SideinfoBoxContents($contents));

$this->table_cellpadding = '0';

$this->table_parameters =

'class="SideinfoBox"';

$this->tableBox($info_box_contents, true);

}

function SideinfoBoxContents($contents) {

$this->table_cellpadding = '0';

$this->table_parameters =

'class="SideinfoBoxContents"';

$info_box_contents = array();

$info_box_contents[] = array(array('text' =>

tep_draw_separator('pixel_trans.gif', '100%', '1')));

for ($i=0, $n=sizeof($contents); $i<$n; $i++) {

$info_box_contents[] = array(array('align' =>

(isset($contents[$i]['align']) ? $contents[$i]

['align'] : ''),

'form' =>

(isset($contents[$i]['form']) ? $contents[$i]['form']

: ''),

'params'

=> 'class="boxText"',

'text' =>

(isset($contents[$i]['text']) ? $contents[$i]['text']

: '')));

}

$info_box_contents[] = array(array('text' =>

tep_draw_separator('pixel_trans.gif', '100%', '1')));

return $this->tableBox($info_box_contents);

}

}

What we have done here is create an extra portion of code to allow us to

differentiate between a “side” infoBox and a “normal” infoBox.

Page

To improve is to change; to be perfect is to change often.

 

Posted

Joli - did you read the whole thread??

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

Joli - did you read the whole thread??

yes

To improve is to change; to be perfect is to change often.

 

Posted

yes

well think so

you want a new box

 

change the following code:

new infoBoxHeading

to:

new SideinfoBoxHeading

And:

new infoBox

to:

new SideinfoBox

To improve is to change; to be perfect is to change often.

 

Posted

here's a question.. why do they even have the box class creator? Couldn't you just add a class to the table (like in burt's suggestion)?? I mean, to build a basic CSS class from php seems a little wild to me. I am thinking I can probably remove the classes/boxes.php file and all references to the class and replace them with a simple <div id=#classname"> and we can work much much more easily

There is a contribution for removing all of the tables and using the div and css method.

 

If you want remove the box class just remember it used all throughout osc. You could probably look at the contrib for some guidence though.

Posted

then style sheet

 

TD.SideinfoBoxHeading {

font-family: Verdana, Arial, sans-serif;

font-size: 12px;

font-weight: bold;

background: #cccccc;

color: #000000;

font-variant: small-caps;

}

 

or somthing???

 

and you have new class that is what you were asking for???

To improve is to change; to be perfect is to change often.

 

Posted

If you read the whole thread.. I figured it out and it wasn;t a cut and dry situation because I have the CSS module installed which removes ALL tables.. Also, others already posted, in this thread, how to make a new class.

 

read the whole post.. otherwise you are kinda wasting your time..

A great place for newbies to start

Road Map to oscommerce File Structure

DO NOT PM ME FOR HELP. My time is valuable, unless i ask you to PM me, please dont. You will get better help if you post publicly. I am not as good at this as you think anyways!

 

HOWEVER, you can visit my blog (go to my profile to see it) and post a question there, i will find time to get back and answer you

 

Proud Memeber of the CODE BREAKERS CLUB!!

Posted

How to add a new box class?

That was your heading that is what people will read!!

I think that was also my answer.

 

:P

To improve is to change; to be perfect is to change often.

 

Posted

The first post in this thread has a tableless box class that can be styled in CSS. It's only the Product table, but the others shouldn't be that hard to do.

 

The box class was intended to make all of the boxes the same. This eliminates duplicate coding and enforces consistency. Converting the box class to a tableless design would make the tables easier to style without introducing inconsistencies or using a lot of copy-and-paste coding.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...