Hi,

just in case you are still working on that problem, here is my little Howto
to the problem:

1. create a user 'user' with password 'password'
2. create topic to store your new articles in (remember it's id)
3. make sure this topic is owned by 'user'
4. now the code:

<?
// before any output is done the next lines have to be executed !!

$log_me_in = mgd_auth_midgard(user,password,1); // 1=cookie , 0=no cookie
if (!$log_me_in)
   {
   die ("Not Authenticated!"); //user doesn't exist or wrong login or
password
   }
$midgard = mgd_get_midgard();
?>


<?
// lets create an article
 $up       = 0;
 $topic    = 27;            // id of your created topic
 $name     = "$nachname";   //those variables are taken from some form
 $title    = "$vorname";    //i know its a little stupid declaring a
variable as
 $abstract = "$sonstiges";  //another one, but its easier to keep track this
way...
 $author   = $midgard->user;//author has to be the 'user' authenticated
above
 $calstart = "0000-00-00";
 $content  = "$kommentar";
 $url      = "";
 $caldays  = 0;
 $icon     = 0;
 $view     = 0;
 $print    = 0;
 $extra1   = "";
 $extra2   = "";
 $extra3   = "";
 $type     = 0;

//testoutput - just to see if all variables are set correctly, uncomment in
case of error
/*
$logged_in = $midgard->user;
echo "logged in is: $logged<br>";
echo "and author: $author<br><br>";
echo "topic: $topic <br>";
$topic_2 = mgd_get_topic($topic);
echo $topic2->name;
echo "<br>this should be the topic your articles go into..."
echo "<br><br><br><br>";
*/
//-- end of testoutput

mgd_errno();           //clear errors, just to make sure...
 $article = mgd_create_article( $up, $topic, $name, $title, $abstract,
$content,
                                $author, $url, $calstart, $caldays, $icon,
                                $view, $print, $extra1, $extra2, $extra3,
                                $type);
 if( ! $article ) {
        echo "Article could not be created!!!<br>";
        echo "Reason: " . mgd_errstr();
}
else {
        // lets put some extra parameters into the articles
        // cause my form contains lots of questions ;-)

        $params = mgd_get_article($article);
        $params->parameter("details","email","$email");
        $params->parameter("details","phone","$phone");
        //and so on..
        echo "Creation of article successfull!<br>";
 }
?>


That is how it worked for me...
Of course you could do the whole creation the oop way also.
Please Note: AFAIK you can only add/change parameters AFTER the article is
created.
(Thought I could enter all data as parameters while creating the article,
but got an error.
It gave me a few minutes to think until --> dooh,stupid me ;-))


Hope I could help,

Alex


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to