Hi everyone,

I'm trying to print certain attributes created from EC Live Subproducts. These belong to a content type I created called "products".

I have used

<pre>
<?php print_r($node); ?>
</pre>

and under the [content] array I see:

[subproduct-attributes] => Array
                (
                    [#weight] => 1
                    [#value] => 
Length

	
Size

	
Price: $15.00


                    [#printed] => 1
                )

and under Length & Size there appears a drop down list of my different variations.

I have tried using

	print $node->content['subproduct-attributes']['value'];
	

in my node-products.tpl.php but nothing happens. Could anyone please point me in the right direction? Thank you very much!

Comments

pepito3eb’s picture

Is there anyone who can help me out? I'm trying really hard to get this to work...

cghobbs’s picture

I'm also really needing to get this working. I'm working on this for a site tonight, so if I find anything I will post back and let you know. In the mean time, does anyone know a solution?

cghobbs’s picture

pepito3eb and anyone else needing to know how to do this,

My mistake was quite dumb. Make sure you actually have sub attributes checked off for the product otherwise you won't get anything returning. But once you do you should be able to very easily add print out the form for choosing the options:

<?php
if ($node->ptype == 'ec_live_subproducts_tangible') {
  print $node->content['subproduct-attributes']['#value'];
}
?>

And if you want to theme what is returned you can add the following function to your template.php file:

function phptemplate_ec_live_subproducts_pproduct_view(&$form) {
  $output = "";
  drupal_add_js(drupal_get_path("module", "ec_live_subproducts") ."/ec_live_subproducts.js");
  //drupal_add_css(drupal_get_path("module", "ec_live_subproducts") ."/ec_live_subproducts.css");
  foreach (element_children($form["variations"]) as $i) {
    $output .= "<div class='variation'><div class='name'>". drupal_render($form["title"][$i]) ."</div>" ;
    if (!empty($form["vardesc"][$i]["#value"])) {
      $output .= "<div class='vardesc'>". check_markup(drupal_render($form["vardesc"][$i]), $attribute2["format"]) ."</div>" ;
    }
    $output .= "<table><tr>";
    $output .= "<td class='description' id='description-". $i ."' ><p>". drupal_render($form["description"][$i]) ."</td>";
    $output .= "<td>". drupal_render($form["variations"][$i]) ."</td></tr></table></div>";
    unset($form["image"][$i]);
  }
  $output .= drupal_render($form);
  $output = theme("fieldset", array("#children" => $output));
  return $output;
} // theme_ec_live_subproducts_pproduct_view

Note: I commented out the fourth line because I actually didnt want the module's css loaded.

Hope that helps anyone who gets stuck on this.

--
Drupal Web Development by ImageX Media