Have you wondered how to show different images in latest ad list and in search list when no photo is uploaded for that item?
Here is a short tutorial for showing different images according to item parent category.
1. First of all add this code to your theme functions.php
function osc_item_parent_category_id() {
if ( !View::newInstance()->_exists('item_category') ) {
View::newInstance()->_exportVariableToView('item_category', Category::newInstance()->findByPrimaryKey( osc_item_category_id() ) );
}
$category = View::newInstance()->_get('item_category') ;
return (int) osc_field($category, "fk_i_parent_id", "") ;
}
This function will allow you to fetch item parent category id.
2. Now put your png images (You can choose images of any type but for that make changes in code too ) in your theme image folder and name them according to your main category.
Like if your main categories id are 2,8,30,45 than rename images like 2.png , 8.png , 30.png , 45.png
3. Now make some changes to your main.php and searchlist.php
replace this line
<img src="<?php echo osc_current_web_theme_url('images/no_photo.gif') ; ?>" alt="" title="" />
whit this one
<img src="<?php echo osc_current_web_theme_url('images/') . osc_item_parent_category_id() .'.png' ?>" alt="No image available" />
(If you are running any OSX version than Text Wrangler is a good tool to do these things).
All done. TADA!!!
I have tested this with Osclass3.0 only although it may work in other versions too.