XML data into theme_table problems.

Hi, people!

I'm having a few problems importing XML data into theme_table in Drupal 7. I'm getting the error "Cannot use string offset as an array" in my PHP error logs. I'm creating a basic page, with PHP code enabled. As far as I can see, this error is because it is expecting an array and receiving a string. I've been going by the API notes at http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_table.

Basically, I've used a basic PHP XML parser to push the required information into an array, and I've proven that it seems to work as I think it should.

Here's my code. Any help would be massively appreciated. I'm just about tearing my hair out! I am a relative newbie to PHP, so my code is probably absolutely horrible - apologies in advance!

<?php
global $user;
global $headers;
global $rows;
$table_variables = array();
global $table_variables;

if ($user->uid) {
echo "Username: ".$user->name."
";
echo "User ID: ".$user->uid."
";
}

if ($user->uid == 1) $file = "XML/XMLtest.xml";
if ($user->uid == 2) $file = "XML/XMLtest2.xml";

// Start table header/row code
function startElement($parser, $name, $attrs) {

// If the element being parsed is a field, add to table_variables headers array
if ($name == "FIELD") {
global $table_variables;
$table_variables["header"][] = $attrs['ATTRNAME'];
}

Need a Starting Point: Users create form via existing nodes + data input + export to views calc

I've been searching for a while, but I'm afraid I need a bit of help tracking this down. Any help on terms to search for or a base to start digging in would be helpful!

Here's what I want to do:
Create a content type that already contains some information. Although I definitely DO NOT WANT TO BUILD A SHOPPING CART, I'll use the example of an "electronic device" as my content type. I'll create a series of nodes that contain CCK fields for the type of device, brand and model.

With this information in mind, a user can then either use a form or create a new node in which they can use either autofill or drop-down box to select a specific node from "electronic device" content type. Then they'd be able to manually enter in how many of the devices they need. So I'd have a user-defined data set of something like:

Device - Brand - Model - Number
MP3 Player - Apple - Ipod - 5
MP3 Player - Microsoft - Zune - 9
DVD Player - LG - 570 - 2

From this information, I'd like to show the result in a view, with the different fields grouped by device, listing brand and number needed:

MP3 Players
Apple Ipod -5
Microsoft Zune - 9
Total MP3 Players - 14
DVD Players
LG 570 - 2
Total DVD Players - 2

Ok, So I think I can figure out and . My issues is .

Creating my first page in Drupal.

Once I create the page where do I find it on my hard drive? I see I can choose from "filtered html" or "full html". Which is preferred and why?

Thanks a bunch.

Programmatically creating node with taxonomy term creates unexpected behavior

My goal is to create some nodes programmatically and tag them with taxonomy terms on creation. The taxonomy term may need to be created, or if it already exists, just added. I'm currently just using an incrementer as the tag, so if I'm making 5 nodes I want them tagged 0-4. Here is the code:

  //see if this term already exists and fetch it if it does
  $term = taxonomy_get_term_by_name($i);
  
  //if it doesn't exist, make it
  if ($term == array()){
    //make a new class to hold the term for taxonomy 1
    $taxonomy = new stdClass();
    $taxonomy->name = $i;
    $taxonomy->vid = 1;
     taxonomy_term_save($taxonomy);
     //now fetch it so we have it's tid
     $term = taxonomy_get_term_by_name($i);
  }
  
  //set $tid as it's returned from  taxonomy_get_term_by_name
  $tid = key($term);
  
  //tag the node with the appropriate tag
   $node->field_tags['und'][0] = array('tid' => $tid);
  
  //save the tagged node
  node_save($node);
	
  $i++;

When I run this it makes the nodes and terms if needed.

taxonomy_term_data table has the 5 terms in it, named 0-4.

taxonomy_index table has nids 0-4 properly associated with tids 0-4.

Also field_data_field_tags table has the right field_tags_tids 0-4 associated with the right entity_id 0-4.

Parent-menu-ID by node/path

Hey!
On a D7-page I have a menu at the top that only contains the root elements of the specified menu. The other items of this menu - depending on the chosen topmenu-link - will be displayed on the left site via menu_blocks module. No problem so far.
But I need to style the menu on the left depending on the associated root-menu-item. So I need to have someting like the mid of the active menu root item in the menu's classes. Is there any way to do this?

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

Getting phpMyAdmin error
MySQL said: Documentation
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x