*

Redis

  • ***
  • 36 posts
custom fields in publish page
« on: March 08, 2025, 07:19:47 PM »
Hi,

How to display custom fields to a certain category?
So the moment some select Vehicles and then Cars, the custom fields should appear for that category.
At the moment when i select car subcategory, custom fields are shown but all of them ( trucks, motorcycles etc ),
which is irrelevant to user when posting a car.

Or is it possible to disable categories and then post direct from plugin types ?


Thank you

*

Redis

  • ***
  • 36 posts
Re: custom fields in publish page
« Reply #1 on: March 09, 2025, 11:31:06 AM »
I have created only one category, and then preselected that category and i have hidden too. So when someone goes to publish page, then you will have the custom fields shown automatically. Copy and replace the code in item-post.php





Code: [Select]
<div class="in var2">
    <!-- CATEGORY -->
   
<?php if($category_type == 1) { ?>

        <div class="row">
            <label for="sCategoryTerm" class="auto-width">
<?php _e('Category', 'zeta'); ?>
</label>

            <div class="input-box picker category only-search">
                <input name="sCategoryTerm" type="text" class="category-pick" id="sCategoryTerm" placeholder="
<?php echo osc_esc_html(__('Start typing category...', 'zeta')); ?>
" value="
<?php echo osc_esc_html(osc_item_category()); ?>
" autocomplete="off"/>
                <i class="clean fas fa-times-circle"></i>
                <div class="results"></div>
            </div>
        </div>

       
<?php if(!osc_selectable_parent_categories()) { ?>

            <style>.picker.category .option.parent {display:none;}</style>
       
<?php } ?>


   
<?php } else if($category_type == 2 || $category_type == '') { ?>

        <div class="row category simple">
            <label for="catId">
<?php _e('Category', 'zeta'); ?>
</label>

            <!-- Preselect Category 2 -->
            <select name="catId" id="catId">
                <option value="2" selected>
<?php _e('Category 2', 'zeta'); ?>
</option>
            </select>
        </div>

   
<?php } else if($category_type == 3) { ?>

        <div class="row category simple">
            <label for="catId">
<?php _e('Category', 'zeta'); ?>
<span class="req">*</span></label>

            <!-- Preselect Category 2 -->
            <select name="catId" id="catId">
                <option value="2" selected>
<?php _e('Category 2', 'zeta'); ?>
</option>
            </select>
        </div>
   
<?php } ?>

   
   
<?php osc_run_hook('item_publish_category'); ?>



    <div class="row ttle">
        <label for="title[
<?php echo osc_current_user_locale(); ?>
]">
<?php _e('Listing title', 'zeta'); ?>
<span class="req">*</span></label>
        <div class="input-box">
           
<?php ItemForm::title_input('title', osc_current_user_locale(), osc_esc_html(zet_post_item_title())); ?>

        </div>
    </div>

    <div class="row dsc">
        <label for="description[
<?php echo osc_current_user_locale(); ?>
]">
<?php _e('Description', 'zeta'); ?>
<span class="req">*</span></label>
        <div class="td-wrap d1 input-box">
           
<?php ItemForm::description_textarea('description', osc_current_user_locale(), osc_esc_html(zet_post_item_description())); ?>

        </div>
    </div>
   
   
<?php osc_run_hook('item_publish_description'); ?>

</div>

<h2 class="inline">
<?php _e('Pricing options & status', 'zeta'); ?>
</h2>

<div class="in var2">
   
<?php if(osc_price_enabled_at_items()) { ?>

        <label for="price">
<?php _e('Price', 'zeta'); ?>
<span class="req">*</span></label>

        <div class="enter
<?php if($price_type == 'FREE' || $price_type == 'CHECK') { ?>
disable
<?php } ?>
">
            <div class="input-box">
               
<?php ItemForm::price_input_text(); ?>

               
<?php echo zet_simple_currency(); ?>

            </div>
        </div>
   
<?php } ?>


    <!-- CONDITION & TRANSACTION -->
    <div class="status-wrap">
        <div class="transaction">
            <label for="sTransaction">
<?php _e('Transaction', 'zeta'); ?>
</label>
           
<?php echo zet_simple_transaction(true, true); ?>

        </div>

        <div class="condition">
            <label for="sCondition">
<?php _e('Condition', 'zeta'); ?>
</label>
           
<?php echo zet_simple_condition(true, true); ?>

        </div>
    </div>
</div>
« Last Edit: March 09, 2025, 01:23:09 PM by Redis »

*

MB Themes

Re: custom fields in publish page
« Reply #2 on: March 10, 2025, 03:45:48 PM »
Easiest way is to trigger change on category (select first value and trigger change).
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots