Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.

Adding classes to attributes.

Started by inxie on 5 Oct 2012, 12:19 PM · Views: 922

Results 1 to 13 of 13
5 Oct 2012, 12:19 PM
#1
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #1 by inxie

I am trying to follow this tutorial in order to change my attribute radio buttons into images: http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

It requires the radio button to have a class like so: ```
<input type="checkbox" class="styled" />


How can I add a class to my attributes?
5 Oct 2012, 7:12 PM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Post #3 by kobra

They already have a class

.wrapperAttribsOptions

Zen-Venom Get Bitten

6 Oct 2012, 12:55 AM
#5
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #5 by inxie

Design75:

Ok you are right. with flexible attribute all attributes get unique classes

Thank, that's what I needed, unique classes as they will all have different images.

6 Oct 2012, 12:57 AM
#6
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #6 by inxie

kobra:

They already have a class

.wrapperAttribsOptions


As far as I can see that class applies to the label and radio button, I need the radio button to have it's own class.
6 Oct 2012, 3:44 AM
#7
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #7 by gjh42

You can address the label and the radiobutton individually under the wrapper class. If you have Flexible Attributes, it could look like
#wAttrib23 label {}
where 23 is the id of the option name.

To get the selected radiobutton, I would have to look at the code; I don't know off the top of my head how or if it is uniquely identified.

7 Oct 2012, 10:45 AM
#8
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #8 by inxie

I have installed the mod 'flexible attributes'. It doesn't seem to have given my attributes classes as suggested above, here is a screenshot of my source code after installation... http://i47.tinypic.com/209mvf8.png

As you can see we have input type, name, value and id, but no class.

I am trying to customize my attribute radio buttons following this tutorial: http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/
The first thing it requires is for radio buttons to have a class called 'styled'. I don't know if there is an easier way to achieve image radio buttons but so far this is how I plan on achieving it.

So, why hasn't the mod given the radio buttons classes as advertised?

7 Oct 2012, 12:04 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #9 by gjh42

It doesn't need to give the radiobuttno a class if the wrapper for the radiobutton has a class; you can address all of the radiobuttons for Gender with #wAttrib2 input {}, or any one of them like #attrib2-4 {} or #attrib2-5 {}. An id is just as good as a class for styling an element, better in some cases.

7 Oct 2012, 12:20 PM
#10
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #10 by gjh42

Reading the tutorial, I see that it uses javascript to address every instance of input, not individual ones as I thought you wanted. In this case, with js not having the same rules as CSS, you probably do need a class tag on the input itself. That would mean editing the tpl_ file, probably.

8 Oct 2012, 12:45 AM
#11
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #11 by inxie

Yes your right, the tutorial is to change all radio buttons to the same images. I need unique images but as a starting point I felt I needed to at least get an image change working before attempting unique images.

As you know I am new to this side of web development and finding it increasingly difficult to understand how to interlink JS, CSS and PHP scripts. Starting from the basics and building from there seems the easiest way to go about it right now.

8 Oct 2012, 1:13 AM
#12
inxie avatar

inxie

Zen Follower

Join Date:
Jul 2011
Posts:
177
Plugin Contributions:
0

Post #12 by inxie

That tutorial is a hoax, it doesn't work never will im tired of spending hours on bull**** scripts that just make me feel stupid when they don't work despite reading the tutorial 100 times over word for word.

8 Oct 2012, 2:26 PM
#13
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #13 by gjh42

I expect the tutorial would work as presented for a custom-written page in flat HTML. However, it needs to be adapted to work with a dynamically generated page such as Zen Cart builds, and that requires some PHP knowledge as well as probably HTML and javascript skill.

Let's talk about what you really want to achieve, and I can advise you on the best way to do it (as long as it doesn't require custom javascript).