I have a CMS, an Intranet for my teammates, we are working every day on this intranet.
We have a team list page, with different access for each teammate.
For go finishing the intro, We too have, an update.php page, that the page, is executed automaticaly when a teammate was promoted or relegated.
When I had drupal 6, the script was worked always, as good as We needed.
But when We upgrade drupal from version 6 to version 7, the script works today, but the changes on the database, Are not reflected on the website.
How I can update the content of a specific page, from the database?
The update.php page:
<?php
if ($_POST['pass'] != "*********")
die ("Stop It now!");
$pre = "<b>Oficial page with the list of team members</b>.\n<!--break-->\n";
$pre .= $_POST['html'];
$cnx = mysql_connect("localhost", "na*****_h***", "*********") or DIE(mysql_error());
mysql_select_db("na*****_h***", $cnx);
if(get_magic_quotes_gpc())
{
$pre = stripslashes($pre);
}
// a mySQL connection is required before using this function
$data = mysql_real_escape_string($pre);
mysql_query ("UPDATE home_field_revision_body SET body_value='$data' WHERE entity_id='5'");
echo "Actualizado correctamente";
mysql_close($cnx);
?>
Comments
There are all sorts of
There are all sorts of problems with that script. It's entirely not Drupal. It uses $_POST data (which we don't use in Drupal). It's bypassing the Database API and using msyql database functions. And it's directly outputting data rather than using Drupal's API to create messages.
I don't think you'll find a lot of help here, as people here generally give Drupal assistance, and that script isn't Drupal.
I correct myself.
Seeing your answer... I am changing the method of do it... Now I create a module natasha_team and I am testing with this code:
But when the cron is executing, I have this error line:
In Drupal 7, this doesn't
In Drupal 7, this doesn't exist:
You'll need to examine an existing node to get the path to the body field. I can't remember what it is off the top of my head, but in D7, it's a field (known as CCK in D6), so the path is something like:
Note two things:
1) If you see 'und' in the path to a value, it should be written as LANGUAGE_NONE in your code, like I have done above.
2) This thread should be moved to the Module Development and Code Questions section of the forum. You can move it by editing the original post and choosing that section as the forum.
Thank you.
Well... I am continue to
Well... I am continue to trying to solve this question. I use your code "$node->body_field[LANGUAGE_NONE][0]['value'];" but the error, continue.
Code that I am using now:
Error message that I receive when the cron is executed:
Certainly, I will continue to seek on drupal, the right way to use the API and edit the content of the page. But I am open to receive other answers. Thank you so much.
As I said, you'll need to
As I said, you'll need to examine an existing node to find out the actual path to the body field - I just gave an example, I didn't (and don't) think it is correct. I was just giving you the overall idea on how to do it.
I can't understand how can I
I can't understand how can I find the really path.
Can you help me again?
_
output $node either using dpm (if you use the devel module, highly recommended) or print_r if you don't.
Well... Now I have the full
Well... Now I have the full path. But..... It doesn't work.... Please, see the path:
The thing is, if i use this: $node->body_field['und'][0]['value'] = 'foo';
Nothing Changes...
@Edit: I am using: $node->body['und'][0]['value'] = 'foo'; <-- And It works so good!!! Thank you SO MUCH to all of users that help to me.
Glad it worked. Note that you
Glad it worked. Note that you should use this instead: