This is G o o g l e's cache of http://www.ubercart.org/forum/ideas_and_suggestions/1011/make_your_code_... as retrieved on Aug 4, 2007 00:56:07 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:XOBMf7qsK6oJ:www.ubercart.org/forum...
Google is neither affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: druru
Ubercart
* Home
* Documentation
* Forums
* Issues
* Livetest
Home » Forums » Ubercart » Ideas and Suggestions
Make your code XHTML valid
Submitted by zmove on Fri, 06/01/2007 - 05:06
zmove
Posts: 33
Joined: 03/23/2007
Brain Stormer
Hi there,
I'm theming shopping cart... panes.. and I saw that there are a lot of tag that includes design in them (like align="center" etc...)
In addition, some of these tags are not in theme_ functions, so it's impossible to change them without modify core (and modify a core module is the hell, so we can say that it's impossible).
for example, the function which show the shopping cart pane on the checkout.
function _cart_review_table() {
$items = uc_cart_get_contents();
$subtotal = 0;
$output = ''
.''
.''. t('Qty.') .''
.''. t('Products') .''
.''. t('Price') .'';
foreach ($items as $item) {
$rows = array();
foreach($item->options as $option){
$rows[] = $option['attribute'] .': '. $option['name'];
}
$desc = $item->title . theme('item_list', $rows, NULL, 'ul', array('class' => 'cart-options'));
$total = ($item->qty) ? $item->qty * $item->price : $item->price;
$subtotal += $total;
$qty = ($item->qty) ? $item->qty : '';
$output .= ''. $qty .'x'
.''. $desc .''
. uc_currency_format($total) .'';
}
$output .= ''. t('Subtotal:')
.' '. uc_currency_format($subtotal) .'';
return $output;
}
There are a lot of tag that includes design tag, it's not good. I think with a better use of classes, everybody could design them how they want with only CSS.
Maybe I'm wrong but I'm a fervent defensor of W3C recommandations, and the choice of drupal was made with that in my head (drupal is a rare CMS with tableless design...) So it's a pity to have ubercart with a lot of table design and doesn't respect W3C standard.
* Add new comment
permalinkFri, 06/01/2007 - 07:32
Ryan
Posts: 1693
Joined: 09/26/2006
AdministratorCode Monkey Head - I eat bugs.
hehe Well, there you have it. Shocked
Yeah, the cart system is probably going to be the main offender here. It was the first bit of code and was really quasi-concept code that just never got reworked. I'm happy to massage the kinks out of it, but I really don't know all the places where I've done things like that.
Actually, a couple releases ago I had put on my list to go through and clean up/consolidate the CSS files but was never able to get to it. If this is something of a specialty for you, I'm happy to make any recommended changes. Be brave with the critique, you won't hurt my feelings. Cool
* reply
permalinkFri, 06/01/2007 - 08:17
zmove
Posts: 33
Joined: 03/23/2007
Brain Stormer
I'm really better in XHTML + CSS than PHP so I think I can help you for that.
The 2 things I can advice you for the instance is :
- Never put attributes like , if you have to mention an exception for a td alignment, make it like that : ". It's the same result and the second one is W3C standard valid.
In addition, avoid if possible styling in your php function even if you use the valid style attribute. Prefer the use of classes. Why ? :
- Because if you put a center align to a in your function (the td to show the product) and I want to left align my product. If it's a theme_ function, I can redeclare it on my template.php and it's good (but redeclaring a function to change an align is like destroy a mouse with a nuclear launch.. ^^). If the function is not a theme_ function, I have it in the ass. So it's not cool.
If you put a class on your td example : I can design it how I want with CSS.
That's why the use of class is recommanded, in addition, the name of class musn't have to descrive a design, because if you put a class in your td named left-align and in my CSS I align the td to the right, it become a nonsense. So the name of the classes have to describe the content, not the form.
The cart and checkout system contain a lot of tables so, in my opinion, that is a template that allow to design table how you want.
For me, that is a basic template for all your table you should use (example with shopping cart) :
ProductQuantityPriceDelete ?
My first product name310$Delete checkbox
My second product name120$Delete checkbox
My third product name270$Delete checkbox
* With the class of a table you can easily theme it and the theme can differ from another table.
* With the "odd" and "even" class to and you can easily make horizontal and vertical zebra design
* With "first" and "last" class to and you can easily control borders that are often a problem on a table (when you don't want left border for the first and right border for the last
* In general with this template, you can easily design all your ubercart tables with a couple of CSS rules and, in addition, you can control precisely the display of one specific table, so there are no week points
* reply
permalinkFri, 06/01/2007 - 16:53
druru
Posts: 225
Joined: 03/21/2007
Brain Stormer
I recently posted to request replacement of hardcoded "presentation" code with a theme function.
I agree that anywhere (or at least most places) uc presents html for display in a browser should ideally be replaced by easily reuseable theme functions for end user customization without hacking core.
It will allow uc to look however endusers want it to look (fully customizable) which can only be a good feature.
zmove nails it with the liberal use of class names to make this work.
And as themeable functions, every aspect of the function (presentation) can practically be overriden by the end user.
* reply
permalinkSat, 06/02/2007 - 06:25
kulvik
Posts: 77
Joined: 12/20/2006
Brain StormerBug Finder
I have to say that I totally agree to the need for removing all that static table stuff. However, instead of just making themeable functions with valid tables, I would love to see that the tables go away once and for all. In example the cart is not a very complex design element and could easily be built on pure divs and CSS. That would make it even easier to theme. You can do a lot of stuff with a table once you use classes, but it's still a table Eye-wink
Any thoughts on this approach?
--
Thomas Kulvik
Ny Media AS
www.nymedia.no
thomas (at) nymedia.no
* reply
permalinkSat, 06/02/2007 - 15:49
druru
Posts: 225
Joined: 03/21/2007
Brain Stormer
kulvik,
ultimately you're probably right about this. in theory divs / no tables is better - semanticly, web2.0, leaner code etc...
fwiw, i still DO use tables for SOME basic structures even though i'm fully aware of the benefits without them and the trend is mostly away from them. My rationale is:
1) i still find cross browser compat to be a pain in the rear for some of the non table stuff (float / divs). When IE6 is long gone that will be a different matter but i still find enough issues to make me choose a basic table populated with divs verus pure divs sometimes. using divs is sometimes kind of like shifting your problems away from the html to the css that presents it (e.g. the html is usually cleaner, leaner and more semantic but your css becomes more difficult and bloated). and it's the uc team that has to deal with the compatability of the css which might be lower on the totem pole versus getting pure features out the door right now.
2) although very rare in the real world, if you disable css, you lose all your float presentation. the one real beauty of tables i've never seen anybody discuss is that when you disable css, your tables are still there (e.g. your menu header is at the top and your side nav on the left and content centered, etc). yeah, it's a lot of extra bloat code but you can rest assured your page structure will always look good.
Anyway, i basically agree with you. It's a matter of whether the uc team feels like swapping tables for divs or some aspect of it right now, later or never.
I think the FIRST step regardless of the switch from tables is to move presentation code to theme functions. Then if you want to change the presentation locally to divs and muck with the css it's entirely up to you and possible.
Good points though.
* reply
permalinkSat, 06/02/2007 - 17:35
kulvik
Posts: 77
Joined: 12/20/2006
Brain StormerBug Finder
Thanks for the reply. Since we are talking about rather simple content I do believe that it would be easy to get a standard "theme" with pure divs and CSS working in all the mayor browsers (even IE 6, that old bitch browser). But you do have a good point: I also hope that the team now have "getting the ubercart 1.0 version released" on the top of their priorities.
This stuff is just considerations and ideas for later. However, getting themeable functions and using classes should be fixed rather quickly. I think a lot of people trying to use ubercart for the first time are scratching their heads trying to figure out how to theme things the way they want, without violating the core Smiling
--
Thomas Kulvik
Ny Media AS
www.nymedia.no
thomas (at) nymedia.no
* reply
permalinkWed, 06/27/2007 - 17:35
TheOverclocked
Posts: 73
Joined: 05/26/2007
Getting busy with the Ubercode.
Any updates on this? I will be making some code changes so that my page validates XHTML Transitional. Though the changes on the Ubercart module(s) will still be XHTML Strict valid. The only reason I have my page in Transitional is so I can use target="_blank" on my links. I know you can do the same thing with javascript, but that seems foolish to me. Another alternative is to use php to achieve the effect, which when I have the time I will write a module to do it.
I can document the changes I make to achieve valid xhtml if you would like so you can make the appropriate changes for Alpha 7?
--
Drupal and vBulletin have united. Meet Drupaltin.
* reply
permalinkThu, 06/28/2007 - 11:06
TheOverclocked
Posts: 73
Joined: 05/26/2007
Getting busy with the Ubercode.
Here are the changes to fix some 10-15 errors, and change all styling to CSS only. I used line numbers out of the module I had from when alpha 6c was just released. All line numbers correspond to the original line numbers.
XHTML Strict 1.0 valid
http://forums.theoverclocked.com/showthread.php?p=12182
More on the way.
--
Drupal and vBulletin have united. Meet Drupaltin.
* reply
permalinkThu, 06/28/2007 - 12:24
Ryan
Posts: 1693
Joined: 09/26/2006
AdministratorCode Monkey Head - I eat bugs.
Awesome. Keep 'em coming. If they don't go in immediately, we'll apply them sooner or later... definitely needs to happen. Smiling
* reply
permalinkFri, 06/29/2007 - 06:53
bwv
Posts: 214
Joined: 02/27/2007
Uber DonorBug Finder
overclocked: I applied your changes to my uc_cart.module and to the block.css and the page appearance has not changed at all -- which means your alterations are perfect. Thank you!
--
========
http://greystokefarm.com/store
Running Drupal 5.1, UC Alpha7c, PHP 5.2.1, MySQL 5.0.37, Apache/1.3.33
* reply
permalinkFri, 06/29/2007 - 06:54
bwv
Posts: 214
Joined: 02/27/2007
Uber DonorBug Finder
reclaiming juice lost to ryan.
Eye-wink
--
========
http://greystokefarm.com/store
Running Drupal 5.1, UC Alpha7c, PHP 5.2.1, MySQL 5.0.37, Apache/1.3.33
* reply
permalinkFri, 06/29/2007 - 07:11
Ryan
Posts: 1693
Joined: 09/26/2006
AdministratorCode Monkey Head - I eat bugs.
"reclaiming juice lost to ryan. Eye-wink "
lol I lost some yesterday, so I guess it's more like a karma system than a rewards system. Actually, I've looked through the issue queue @ Drupal for User Points, and no one seems to notice this bug. I'll get it straightened out eventually..
* reply
permalinkFri, 06/29/2007 - 11:32
TheOverclocked
Posts: 73
Joined: 05/26/2007
Getting busy with the Ubercode.
Glad to hear that bwv. I actually made one change but still have not perfected it. The code I posted takes the arrow and pads it against the title text. I changed it so it stays in the top right corner at all times even if the block gets squished. Not much difference really. The only thing I'm having problems with is the javascript. It works fine in firefox, but in IE6 the arrow wont flip. I'm still ironing out a lot of css issues in IE6 though Sad
If you want to see what I mean, goto http://**removethis**starchman7.getmyip.com:6464/hp/ (don't want bots going there), and to get the cart block to show just add one of the coffees.
Let me know if you want the changes to make it that way.
--
Drupal and vBulletin have united. Meet Drupaltin.
* reply
permalinkFri, 06/29/2007 - 12:21
bwv
Posts: 214
Joined: 02/27/2007
Uber DonorBug Finder
Karma, eh? Take your time, its sort of fun embarrassing you.
--
========
http://greystokefarm.com/store
Running Drupal 5.1, UC Alpha7c, PHP 5.2.1, MySQL 5.0.37, Apache/1.3.33
* reply
permalinkFri, 06/29/2007 - 12:47
bwv
Posts: 214
Joined: 02/27/2007
Uber DonorBug Finder
Hi Overclocked. I fooled around with the CSS and was able to position everything very nicely, thanks.
But now I am beginning to wonder whether the changes I made (using the example you posted on your other web page forum) might have resulted in the difficulties I am having with JS in admin/edit mode.
See this thread please for more info:
http://www.ubercart.org/forum/support/1227/expandable_fields_edit_mode_n...
Have you had any similar problems when trying to edit a product page?
Thanks
--
========
http://greystokefarm.com/store
Running Drupal 5.1, UC Alpha7c, PHP 5.2.1, MySQL 5.0.37, Apache/1.3.33
* reply



Joined: 08/07/2007