Advertisement:

Author Topic: {Solved} Auto-select a category when adding new ad ?  (Read 899 times)

mikedukie

  • Newbie
  • *
  • Posts: 8
{Solved} Auto-select a category when adding new ad ?
« on: May 16, 2016, 03:46:11 pm »
Hello everybody,

On my website I got only one category.

I need to know how to auto-select this only existing category when adding a new ad, and how to hide this field from the user ?

Osclass 3.6.1
Theme Wizestate

I imagine it's in item-post.php :

Code: [Select]
<div class="form-group">
            <label class="control-label" for="select_1">
              <?php _e('Category'OSCLASSWIZARDS_THEME_FOLDER); ?>
            </label>
            <div class="controls">
              <?php  if ( osc_count_categories() ) { ?>
<?php if(osc_get_preference('category_multiple_selects''osclasswizards_theme') == '1'){ ?>
  <div class="cat_multiselect"><?php ItemForm::category_multiple_selects(nullnullnullosc_esc_html(__('Select a category'OSCLASSWIZARDS_THEME_FOLDER))); ?></div>
<?php }else{ ?>
              <?php ItemForm::category_select(nullnullosc_esc_html(__('Select a category'OSCLASSWIZARDS_THEME_FOLDER))); ?>
<?php ?>
              <?php  ?>
            </div>
« Last Edit: May 16, 2016, 05:08:38 pm by mikedukie »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Auto-select a category when adding new ad ?
« Reply #1 on: May 16, 2016, 04:55:47 pm »
Hi,

1.- Admin Dashboard:

    1a.- Make sure that Settings / General / Parent categories is ticked.

    1b.- Make sure that Appearance / OsclassWizards / Templates / Item Post / Category multiple selects is OFF.
 


2.- item-post.php, replace this block:

Code: [Select]
          <div class="form-group">
            <label class="control-label" for="select_1">
              <?php _e('Category'OSCLASSWIZARDS_THEME_FOLDER); ?>
            </label>
            <div class="controls">
              <?php  if ( osc_count_categories() ) { ?>
<?php if(osc_get_preference('category_multiple_selects''osclasswizards_theme') == '1'){ ?>
  <div class="cat_multiselect"><?php ItemForm::category_multiple_selects(nullnullnullosc_esc_html(__('Select a category'OSCLASSWIZARDS_THEME_FOLDER))); ?></div>
<?php }else{ ?>
              <?php ItemForm::category_select(nullnullosc_esc_html(__('Select a category'OSCLASSWIZARDS_THEME_FOLDER))); ?>
<?php ?>
              <?php  ?>
            </div>
          </div>

with:

Code: [Select]
<input type="hidden" name="catId" id="catId" value="1" />
(If your single category doesn't have ID 1, change value here)

Regards

mikedukie

  • Newbie
  • *
  • Posts: 8
Re: Auto-select a category when adding new ad ?
« Reply #2 on: May 16, 2016, 05:08:13 pm »
Thank you! :)

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: {Solved} Auto-select a category when adding new ad ?
« Reply #3 on: May 16, 2016, 05:14:14 pm »
You're welcome. :)

Regards