I have a store running on osCommerce. I would like a user's chosen theme to carry over to the shop when they go there and out of the Drupal area. For instance, some of my users cannot stand white screens and prefer the black background with green text theme. Is there a way, perhaps via cookies, to pass this information on to osCommerce so it can apply the coridinating style sheet to its own pages?

Thanks heartily!

Comments

CrowChick’s picture

I hate to do it, but I'm bumping this.

CrowChick’s picture

Stillllll bumping.

eaton’s picture

... without essentially porting the theme to whatever templating system oscommerce offers. Does it have any built-in theming capabilities?

--
Jeff Eaton | I heart Drupal.

--
Eaton — Partner at Autogram

CrowChick’s picture

No, osCommerce has no native theme capabilities that I am aware of just a stylesheet. But I could tweak it to switch stylesheets with cookies. It would be nice if Drupal could communicate with osCommerce via cookies what the user prefers.

ixis.dylan’s picture

I'm certain that OSCommerce supports templates of some kind. You're going to have to write one (or buy one) that mimics your Drupal themes and then pass that information to OSCommer somehow.

Alternatively, you could try the ecommerce module and run everything from Drupal? This probably isn't very practical, but it's the best way to get a consistent theme across the various parts of your site.

demolicious | leafish

CrowChick’s picture

Out of the box, it's about as templated as any higgledy-piggeldy homemade php site. You can use an add-on that converts the entire thing to a table-centric template system, but yuck. Tables are the devil! I've never had a problem with just abusing the style sheet.

I don't need or want the Drupal menus, so all I really want to know is how do I pass on what theme the user is using (default or specified) and tell osCommerce to haul out the coordinating style sheet. I've read skinning tutorials where users can change the css and/or php of a site via info stored in cookies.

I've already got the store running on one site, and I want to run it on this one, too, from the same database. Hence, I am most hesitant to wrangle yet another ecommerce thingermajiggy when I already have a fully customized one at my disposal :D I refuse to keep inventing the wheel! lol

eaton’s picture

Cookies won't help osCommerce look like Drupal unless the stylesheets and HTML used on the osCommerce portions of the site match the HTML and stylesheets used on the Drupal side.

Cookies are just a way of passing bits of data around -- the work of doing the layout and style customization on osCommerce still has to be done.

--
Jeff Eaton | I heart Drupal.

--
Eaton — Partner at Autogram

CrowChick’s picture

I don't need the Drupal navigation system on the oscommerce pages. I just need the general colors to match up. I have viewers who prefer a black background to a glaring white one, and I'd like to accomodate their choices.

How does Drupal store the user's preferences in regards to site theme? In the database?

heine’s picture

You'll have to pass the theme info in some way, perhaps as a 'get' argument to osCommerce.

To know the current theme you can use the global variable $theme. For example create a story, set filter to 'php' and enter:

  global $theme;
  print $theme;

This outputs... nothing (!) because the theme system has not been initialised yet. To do so, execute theme() (drupal 4.6 only):

  global $theme;
  // Initialise the theme system
  if (!isset($theme)) {
    theme();
  }
  print $theme;

outputs 'bluemarine' on a default drupal installation.

Caveat: this code detects the theme, not the style used. Eg. for box_cleanslate it would output box_grey. I'm still looking into this (but it's 3am, so I'm not sure if I can get it done before tomorrow)

edit: minor corrections
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

heine’s picture

You can get the stylesheet(s) with a call to theme_add_style() without arguments. You'll actually get an array with paths to styles.

  if(!isset($theme)){
    theme();
  }
  $s tyle = theme_add_style();
  print $s tyle[0];

(leave out the spaces in style)

On box_cleanslate this will result in themes/box_grey/box_cleanslate/style.css

whereas bluemarine as theme will result in themes/bluemarine/style.css

(i couldn't add a third code block so it had to go in its own comment)

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

linulo’s picture

How does Drupal store the user's preferences in regards to site theme? In the database?

Yup, the users's theme selection is stored in the users table in the theme column. I would pull it from there, map it to the corresponding osCommerce style.

This would mean hacking that database query into osCommerce. If you do not want to have that extra query in all your osCommerce pages you can still set a cookie in osCommerce once the user's theme has been read.

CrowChick’s picture

All right, now I know what I'm working with! I just have to learn more about cookie wrangling. (I am a such newb.) Anyone have an example of how you might store that information in a cookie?

linulo’s picture

Just take a look at http://www.php.net/setcookie. There are explanations, code and examples.