Results 1 to 2 of 2

Thread: Adding a checkbox to the ad submission

  1. #1
    Thread Starter
    Member ancient-geek's Avatar
    Join Date
    Jan 2010
    Location
    Darlington, UK
    Posts
    76
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Adding a checkbox to the ad submission

    As a copy and paste programmer I am chuffed to share a mod that I just cracked and I am very pleased with myself. Steely eyed programmers will sniff at such things but I am not daunted. As yet, untainted by the trappings of success in the world of programming, I offer you:
    How to put a check box item on your ad submission page.

    I wanted a box, where registered traders will be asked to tick a box so that potential buyers know it's a trader or a regular punter. (I don't know whether it's a requirement in the UK but newspaper ads always come with a (T) printed on them in such cases, so I thought I better had too)

    Anyway, of course, you can use it to your own end. Clearly, just change the variable 'trader' and the echoed text
    (Note, line numbers are approximate, so be careful )

    In Form_process.php
    Insert the following around about line 31
    Code:
    if ( cp_filter($_POST['trader']) == "1") {
    	$trader="Yes";
    } else {
    	$trader="No";
    }
    In post-form.php
    Insert the following around about line 224
    Code:
    <div class="extrasbox">
      <div style="margin: 10px 10px 10px 10px ;">
      <span class="alignleft" ;"><input name="trader" value="1" type="checkbox" <?php if ($_POST['trader'] == '1') { echo "CHECKED";}  ?> /></span>
      <?php _e('Please tick the box if you are a trader','cp'); ?> <?php echo get_option('trader'); ?>
    
      </div>
    </div>
    and Insert the following around about line 167
    Code:
    add_post_meta($post_id, 'trader', $trader, true);
    In single.php
    Insert the following around about line 44
    Code:
    <?php _e('Trader '); ?>: <?php echo get_post_meta($post->ID, "trader", true); ?>
    After spending the last three weeks tweaking this theme out of site, I am feeling very pleased with myself.
    I hope it's useful to someone.

  2. #2
    pepsi's Avatar
    Join Date
    Mar 2009
    Location
    New Zealand
    Posts
    14,883
    Thanks
    91
    Thanked 804 Times in 718 Posts

    Re: Adding a checkbox to the ad submission

    That's awesome, thanks for sharing

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)