I am attempting to set up a way for customers to purchase ad space. So far I have the advertisement, Ubercart, and pay-per-node modules working pretty well. I have run into a problem that I need to solve.

When a visitor purchases an ad everything works great except for the fact that the ad they create is put into the "default" ad group instead of the selected group. Looking at the paypernode_ad.module I see the following;

function paypernode_ad_paypernode_form_alter($form, $form_state) {
    //debug($form_state);
    /*
    $form['taxonomy'][_ad_get_vid()]=array(
        '#type' => 'hidden',
        '#value' => $form['#node']->taxonomy[_ad_get_vid()],
    );
    */
    $args=explode(':', $form['#paypernode_type']);
    array_shift($args);
    $form['taxonomy'][_ad_get_vid()]['#disabled']=TRUE;
    $form['taxonomy'][_ad_get_vid()]['#default_value']=$args[1];//$form['#node']->taxonomy[_ad_get_vid()];
    /*
    array(
        '#type' => 'hidden',
        '#value' => $form['#node']->taxonomy[_ad_get_vid()],
    );
    */
    
    // from varaiables
    $form['schedule']['maxviews']=array(
        '#type' => 'hidden',
        '#value' => $form['#node']->maxviews,
    );
    
    return $form;
}

Blackice78, not sure what is going on here but for some reason the taxonomy is not being saved.

I have 3 ad groups, 1 for different sizes of ads (leaderboard, med rectangle, and skyscraper). So the ad nodes need to be put into the correct group so they can be displayed in the correct region without breaking my theme.

I appreciate any help.

Comments

maurizio.ganovelli’s picture

Assigned: Unassigned » maurizio.ganovelli

Hi twooten,

try this code instead:

function paypernode_ad_paypernode_form_alter($form, $form_state) {
    $args=explode(':', $form['#paypernode_type']);
    array_shift($args);
    $form['taxonomy'][_ad_get_vid()]['#access'] = 0;
    $form['taxonomy'][_ad_get_vid()]['#default_value'] = array($args[1]);
    $form['schedule']['maxviews']=array(
        '#type' => 'hidden',
        '#value' => $form['#node']->maxviews,
    );
    return $form;
}

Let me know if works for you (i tried this code with ad 2.2).

maurizio.ganovelli’s picture

Status: Active » Fixed
twooten’s picture

Hi Blackice78,

Just wanted to let you know that your code is working great. Thank you very much!

Tim

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.