2

I'm fairly new to PHP (or programming for that matter) and I've been stuck on an issue for some time now (my logic fails at the moment, please don't judge, I'm learning)

I want to display only specific items on Premium ads. For example there should be ads from Cars, Real Estate but NOT from Dating, Tobacco and so. I looked around but I'm a bit lost. The theme I'm using right now is displaying the Premium ads by the following

<div id="premium" class="products grid">
      <h2><?php _e('Featured listings', 'delta'); ?></h2>

      <div class="block">
        <div class="prod-wrap">
          <?php $c = 1; ?>
          <?php while( osc_has_premiums() ) { ?>
            <?php del_draw_item($c, true, del_param('premium_home_design')); ?>
              
            <?php $c++; ?>
          <?php } ?>

          <?php if(osc_count_premiums() <= 0) { ?>
            <div class="home-empty">
              <img src="<?php echo osc_current_web_theme_url('images/home-empty.png'); ?>" />
              <strong><?php _e('No premium listing yet', 'delta'); ?></strong>
            </div>
          <?php } ?>
        </div>
      </div>
    </div>

For now my approach was to search the forums and find how to display the specific items. I did the following:

    <?php osc_query_item(array(
    "category" => "109,108,107,106,105,104,102,101,100,99,98,257"));

if( osc_count_custom_items() == 0) { ?>
    <p class="empty"><?php _e('No Listings', 'modern') ; ?></p>
<?php } else { ?>
 <div class="home-container premium">
      <div class="inner">
            <div id="premium" class="products grid">
         <tbody>
            <?php $class = "even"; ?>
            <?php while ( osc_has_custom_items() ) { ?>
             
        <tr class="<?php echo $class. (osc_item_is_premium()?" premium":"") ; ?>">
                    <?php if( osc_images_enabled_at_items() ) { ?>
                     <td class="photo">
                        <?php if( osc_count_item_resources() ) { ?>
                            <a href="<?php echo osc_item_url() ; ?>">
                                <img src="<?php echo osc_resource_thumbnail_url() ; ?>" width="75" height="56" title="<?php echo osc_item_title(); ?>" alt="<?php echo osc_item_title(); ?>" />
                            </a>
                        <?php } else { ?>
                            <img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="" title=""/>
                        <?php } ?>
                     </td>
                    <?php } ?>
                     <td class="text">
                         <h3><a href="<?php echo osc_item_url() ; ?>"><?php echo osc_item_title() ; ?></a></h3>
                         <p><strong><?php if( osc_price_enabled_at_items() ) { echo osc_item_formated_price() ; ?> - <?php } echo osc_item_city(); ?> (<?php echo osc_item_region();?>) - <?php echo osc_format_date(osc_item_pub_date()); ?></strong></p>
                         <p><?php echo osc_highlight( strip_tags( osc_item_description() ) ) ; ?></p>
                     </td>                                       
                 </tr>
                <?php $class = ($class == 'even') ? 'odd' : 'even' ; ?>
            <?php } ?>
        </tbody>
    </div>
</div>
</div>
<?php }; ?>

Which works great! Now my issues is I am not able to understand on how to re write the piece of code to actually show my items in the preformatted theme CSS. My guess is that this happens in this line of code (under the preformatted bloc / product wrap)

php del_draw_item($c, true, del_param('premium_home_design')); ?

Any help would be appreciated!

Using this piece of code

<?php osc_query_item(array(
    "category" => "109,108,107,106,105,104,102,101,100,99,98,257"));

if( osc_count_custom_items() == 0) { ?>
    <p class="empty"><?php _e('No Listings', 'modern') ; ?></p>
<?php } else { ?>
 <div class="home-container premium">
      <div class="inner">
            <div id="premium" class="products grid">
         <tbody>
            <?php $class = "even"; ?>
             <?php $itmprem=1;?>
            <?php while ( osc_has_custom_items() ) { ?>
             
        <tr class="<?php echo $class. (osc_item_is_premium()?" premium":"") ; ?>">
        
                    <?php del_draw_item($itmprem, true, del_param('premium_home_design')); ?>   
                    <?php $itmprem++;?>
                 </tr>
                <?php $class = ($class == 'even') ? 'odd' : 'even' ; ?>
            <?php } ?>
        </tbody>
    </div>
</div>
</div>
<?php }; ?>
            </div>

          </div>

        </div>

      </div>

    </div>

  <?php } ?>

Gives me a loop of same item 3 times, from the categories I want, but only that. Yes I know I'm bad, but I fail to see the solution.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38

0 Answers0