Results 1 to 7 of 7

Thread: Questions on tpl-edit-ad.php

  1. #1
    Thread Starter
    Junior Member
    Not a Verified Customer
    hewitt's Avatar
    Join Date
    Apr 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Questions on tpl-edit-ad.php

    I have 3 questions regarding the tpl-edit-ad.php file. Hope someone replies.

    1. I want to remove Price and Location entirely in the Edit Ad page since I don't need them. What codes do I need to edit/remove to ensure the file will work properly?

    2. I created a custom field in the post-form.php ("Car Model"). I want to add this in the tpl-edit-ad.php file and also make it a required field. What codes do I add in that file and do I need to add something in the other files, say in form_process.php?

    3. I want to add the option for users to change the Category. I think this is absolutely necessary especially if users incorrectly assigned a category. What codes do I add to have that Change Category option in tpl-edit-ad.php?

    Thanks!

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

    Re: Questions on tpl-edit-ad.php

    Post moved to relevant thread

  3. #3
    Thread Starter
    Junior Member
    Not a Verified Customer
    hewitt's Avatar
    Join Date
    Apr 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Questions on tpl-edit-ad.php

    Help pls! David? Or other good coders out there? I've been struggling with the tpl-edit-ad.php for days now but I can't still figure out how to do any of the 3 things above.

    Would appreciate any help.

  4. #4
    Member damien's Avatar
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    91
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Questions on tpl-edit-ad.php

    [b]1:

    open form_process.php, find;

    Code:
    if ($post_title == "" || $post_cat == "" || $name == "" || $email == "" || $description == "") {
    		$err .= __('Please fill in all mandatory * fields','cp') . "
    ";
    	}
    remove
    Code:
    $price == "" || $location == "" ||
    open post_form.php and delete:
    Code:
    <label for="price"><?php _e('Price','cp'); ?> <span>*</span> <?php _e('(do not enter currency symbol)','cp'); ?></label>
    				<input type="text" id="price" class="adfields" name="price" size="60" maxlength="100" value="<?php echo stripslashes($_POST['price']); ?>" />
    				
    				<label for="location"><?php _e('Location','cp'); ?> <span>*</span></label>
    				<input type="text" id="location" class="adfields" name="location" size="60" maxlength="100" value="<?php echo stripslashes($_POST['location']); ?>" />
    It's now out of the form and removed as a requirement. You need to edit templates like single.php to remove the other parts where it would show normally.

    2:

    open form process.php and make the changes/add your new field like here;

    Code:
    if ($model == "" || $post_title == "" || $post_cat == "" || $name == "" || $email == "" || $description == "") {
    		$err .= __('Please fill in all mandatory * fields','cp') . "
    ";
    	}
    Code:
    	$cp_adURL 		= cp_filter($_POST['cp_adURL']);
    	$featured_ad	= cp_filter($_POST['featured_ad']);
    	$model	        = cp_filter($_POST['model']);
    Code:
    		add_post_meta($post_id, 'expires', $expires, true);
    		add_post_meta($post_id, 'cp_adURL', $cp_adURL, true);
    		add_post_meta($post_id, 'model', $model, true);
    open post_form.php, add;

    Code:
    <label for="location"><?php _e('Car Model','cp'); ?> <span>*</span></label>
    				<input type="text" id="model" class="adfields" name="model" size="60" maxlength="100" value="<?php echo stripslashes($_POST['model']); ?>" />
    put it where you just deleted the location and price.

    Show it in single.php now

    find
    Code:
    <p class="prdetails">
    ...
    add in it
    Code:
    <?php _e('Car Model'); ?>: <?php echo get_post_meta($post->ID, "model", true); ?>
    last open functions.php and add it to the search function.
    Code:
     $customs = Array('name', 'price', 'phone', 'location');
    Code:
     $customs = Array('name', 'price', 'phone', 'location', 'model');
    Done.

    3

    never tried that yet

  5. #5
    Thread Starter
    Junior Member
    Not a Verified Customer
    hewitt's Avatar
    Join Date
    Apr 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Questions on tpl-edit-ad.php

    Thanks Damien for the reply. #1 worked well.

    For #2, however, the codes you mentioned apply only to the single.php page. I want the required "Model" field also in the Edit Ad page (tpl-edit-ad.php) so that users can also edit the Model info. I successfully added the field in the Edit Ad page but I can't make it show the already inputted Model info. Also I cannot make it required, which means even if there's no info inputted there, if one presses the Submit Ad button, it gets accepted which shouldn't be.

    Any help again is appreciated. Also for my #3 question

  6. #6
    Thread Starter
    Junior Member
    Not a Verified Customer
    hewitt's Avatar
    Join Date
    Apr 2009
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Questions on tpl-edit-ad.php

    Help with #2 and #3 please! Thanks.

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

    Re: Questions on tpl-edit-ad.php

    I'm no expert but I am doing similar tweeks.
    To make a field compulsory you need to add into form_process.php just as you took out location and price.
    Add your field where you took out the others.
    $field == "" ||
    Note, in the syntax, the || is just an OR statement.
    I'm not sure I can help with the other stuff.

Thread Information

Users Browsing this Thread

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