Forums / General Questions / Is there any fast way to update text alignment for ALL product descriptions???

Is there any fast way to update text alignment for ALL product descriptions???

Locked

Views: 2,912

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
10 Oct 2006, 6:33 AM
#1
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Is there any fast way to update text alignment for ALL product descriptions???

I used to have all of my product descriptions centered, but now I'm upgrading, and the product info page has a different layout. I like the new layout better, but it doesn't look good with the centered text. I want to change them to justified, but I have over 500 products and it will take forever! Is there any kind of query I could execute in the database to do this?

TIA!

Danielle

10 Oct 2006, 10:34 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Is there any fast way to update text alignment for ALL product descriptions???

Danielle

Are you using version 1.3.0.2 or 1.3.5?

Do you have an over-ride file for your tpl_product_info_display.php file?

These questions are because you have a div with inline CSS that isn't usually present that is forcing your text to be centrally aligned. If we can track down the source and replace the inline CSS with a class, then you can control the alignment through your stylesheet.

(I'm just hoping that the div isn't a part of every one of your database entries - though even then a quick script could strip them all out)

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

10 Oct 2006, 4:08 PM
#3
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is there any fast way to update text alignment for ALL product descriptions???

Hi, I am using 1.3.5. I do have an override for that file, but only because I added the cross-sell mod. Unfortunately I've been setting the alignment to centered for each product as I've been adding it :cry:

What you said about a quick script that could strip that out is exactly what I'm looking for! I'm just not sure how to do it :blush:

Danielle

10 Oct 2006, 10:18 PM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Is there any fast way to update text alignment for ALL product descriptions???

I started to think about how to construct a script and realised that there is a much easier way to correct this.

Step 1: Do a complete backup of your database by your normal method

Step 2: use phpMyAdmin to export your product_description table only to a file, making sure that you tick the "add drop table" and "add of not exists" boxes

Step 3: open the resulting file in a text editor and use the editor's search & replace facility to replace all instances of <div style="text-align: center;"> with <div class="description">

Step 4: re-import the table via phpMyAdmin

Step 5: add .description {text-align:left} to your stylesheet

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

12 Oct 2006, 5:27 AM
#5
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is there any fast way to update text alignment for ALL product descriptions???

GENIUS! You are a genius! It worked beautifully, thank you!

:jump:

Danielle

12 Oct 2006, 7:59 AM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Is there any fast way to update text alignment for ALL product descriptions???

I'm glad that worked for you. However this was the quick and dirty fix which still leaves you having to add <div class="description"> and a </div> to the product description for each new product.

Now that you've gotten the hang of this approach, you might wish to consider stripping these tags out of your database completely as you can easily attach the CSS styling you want for the description to the #productDescription ID that Zen Cart already inserts for you.

I didn't suggest this originally because of the added complication of also striping out the </div> tags but upon reflection I don't think that would be any more difficult than what you've already done and I should have suggested it before. :blush:

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

12 Oct 2006, 11:25 PM
#7
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is there any fast way to update text alignment for ALL product descriptions???

In new products that I add, wouldn't I just choose the alignment option that I want in the HTML editor? :blink:

If that won't work, what you're basically saying is to go into that same table and remove every instance of <div class="description"> as well as </div>? I'm not sure how well it will work for the </div>, I wonder if that tag is used anywhere else in the product description besides just the alignment?

Danielle

12 Oct 2006, 11:35 PM
#8
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Is there any fast way to update text alignment for ALL product descriptions???

Ahh. That's how this inline styling got into your database. Yes it will work, but each time you hit a function like that in the HTML editor you are inserting unnecessary and difficult to change code into your database for each individual product and re-creating the problem that you started with. It's much better to use the CSS IDs and classes that Zen Cart's php gives you and control the look of your product layouts from a single place in the stylesheet.

The </div> is the closing tag for the <div class="description"> tag. They operate as a pair and must be there or not together. If you took out the <div class="description"> but left the </div>, the latter would close an earlier FIV with potentially catastrophic consequences.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

21 Oct 2006, 6:51 AM
#9
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is there any fast way to update text alignment for ALL product descriptions???

Alrighty, I've stripped all the div tags and justified the products description using the stylesheet. Thanks SO much for all your help :cheers:

In case anyone else is trying this, here is what I added to my stylesheet after I'd stripped all the div tags out:

#productDescription {text-align:justify;}

Danielle

21 Oct 2006, 8:53 AM
#10
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Is there any fast way to update text alignment for ALL product descriptions???

Way to go, Danielle. So glad you bit the bullet and this will not only make it easier to change them again should you wish in future, but also eliminate the risk of forgetting to hit the justify key when entering a product description.:clap:

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

26 Oct 2006, 10:07 PM
#11
danielle avatar

danielle

Totally Zenned

Join Date:
Oct 2004
Posts:
973
Plugin Contributions:
0

Re: Is there any fast way to update text alignment for ALL product descriptions???

Thanks, I'm glad I did it too! I have to admit though, it takes everything I have to not automatically hit one of the alignment buttons in the HTML editor when I'm entering a new product lol! I think I'm just going to stop using the editor, it really only saves a few seconds if that.

Danielle