Article Issue

wibadd 03 Mar, 2012
I previously had this code working before I encountered some SSL issues on my site and had to restore. I cannot figure out why the following code will not set the catid - I am able to set everything else except for this.
if ($form->data['level'] == "Software") {
    $form->data['catid'] = 33;
} elseif ($form->data['level'] == "Gold") {
    $form->data['catid'] = 34;
} else {
    $form->data['catid'] = 35;
}

This code checks out fine in my editor and I only set this once in the form. All the other values set fine. I do not have a value set in the Category drop down in the Submit Article event because I to use the code above to set this. I checked the debugger data and database and there is no value being set for catid, but everything else is fine - here is the rest of the code.

$form->data['publish_up'] = date("Y-m-d H:i:s"); 

$form->data['attribs'] = '{"show_title":"","link_titles":"","show_intro":"","show_category":"","link_category":"","show_parent_category":"","link_parent_category":"","show_author":"","link_author":"","show_create_date":"","show_modify_date":"","show_publish_date":"","show_item_navigation":"","show_icons":"","show_print_icon":"","show_email_icon":"","show_vote":"","show_hits":"","show_noauth":"","alternative_readmore":"","article_layout":""}';

$form->data['metadata'] = '{"robots":"","author":"","rights":"","xreference":""}';

$form->data['language'] = '*';

if ($form->data['level'] == "Software") {
    $form->data['catid'] = 33;
} elseif ($form->data['level'] == "Gold") {
    $form->data['catid'] = 34;
} else {
    $form->data['catid'] = 35;
}

$filename = substr($form->data['logo'],0,strrpos($form->data['logo'],'.')); 
$ext = substr(strrchr($form->data['logo'], '.'), 1);
$form->data['website_logo'] = $filename."_big.".$ext;

if ($form->data['level'] != 'Silver') {
$form->data['sponsor_article_content'] = "<table width='700'><tr><td><a href='http://".$form->data['website']."' target='_blank'><img src='http://wibadd.org/media/media/sponsors/2012/images/website/".$form->data['website_logo']."' style='margin: 0px 5px 5px 5px; float: left;' alt='".$form->data['website_logo']."' /></a></td></tr><tr><td style='text-align: justify;'>".$form->data['description']."</td></tr></table>";
} else {
$form->data['sponsor_article_content'] = "<table width='700'><tr><td><a href='http://".$form->data['website']."' target='_blank'><img src='http://wibadd.org/media/media/sponsors/2012/images/website/".$form->data['website_logo']."' style='margin: 0px 5px 5px 5px; float: left;' alt='".$form->data['website_logo']."' /></a></td></tr></table>";
}

$form->data['subject_line'] = 'New Sponsor - '.$form->data['display_name'];
By the way, you may notice that I have to set the suffix on the image because for some reason the Image Resize event appends this value even though I do not have it configured in the event. It is doing this for all the resized image options that are turned on.

[attachment=1]3-3-2012 2-52-48 AM.png[/attachment]
[attachment=0]3-3-2012 2-51-55 AM.png[/attachment]
GreyHead 03 Mar, 2012
Hi wibadd,

I think I see what the problem is, the action has a drop-down for catid and it takes that value (set to '' here) instead of the one you set in the form. Here's a quick-fix hack. Open administrator/components/com_chronoforms/form_actions/submit_article/submit_article.php and look for this line around line 30
$form->data['catid'] = $params->get('catid', '');
and replace it with these lines
if ( !isset($form->data['catid']) || !is_int($form->data['catid']) ) {
  $form->data['catid'] = $params->get('catid', '');
}

Bob
This topic is locked and no more replies can be posted.