Any PHP inspectors out there?
[FONT="Arial Black"]Background.[/FONT] I need help with tpl_modules_products_new_listing.php where I am successfully using two custom data fields, model name and style. Note that a style value does not necessarily exist but a model name always does. Thus, I am trying to output and display covering the two possible conditions:
- model name | style » iPod | Shuffle
- model » Zune
Note the absence of a style label in the second. This is my trouble, preventing its output when there is no style value.
[FONT="Arial Black"]Question.[/FONT] How do I rework the functioning tpl_modules code shown in purple below so that it outputs labels and data to cover the above two possible conditions?
[FONT="Arial Black"]What works.[/FONT] Figuring out the HTML is easy as is getting the custom data fields to output in display with their labels, but the trouble I am having is the conditional combine and output. Also, I do not mind if a solution involves the code shown in green below which is in the <td>table</td> areas toward the bottom of the modules template file. And yes the configuration table and admin panel are set properly to display the new configuration table rows: PRODUCT_NEW_LIST_STYLE_LABEL, PRODUCT_NEW_LIST_MODEL_NAME and PRODUCT_NEW_LIST_STYLE.
[FONT="Arial Black"]What doesn't.[/FONT] What I've tried is a zen_products_lookup with an if empty statement shown in blue below but my PHP skills are in early beta. Obviously. IOW, I can copy and paste and sometimes manipulate it to get it to do what I want but original coding from scratch is out of the question for me at this stage. I may need examples pointing out where I am going wrong.
Lastly, I will add PRODUCT_NEW_LIST_MODEL_NAME_LABEL components if necessary once I understand how to get the STYLE label working properly.
[FONT="Arial Black"]Functioning code[/FONT][FONT="Courier New"]
if (PRODUCT_NEW_LIST_MODEL_NAME != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'custom_model_name')) {
$display_products_model_name = TEXT_PRODUCTS_MODEL_NAME . $products_new->fields['custom_model_name'] . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_MODEL_NAME, 3, 1));
} else {
$display_products_model_name = '';
}
if (PRODUCT_NEW_LIST_STYLE != '0' and zen_get_show_product_switch($products_new->fields['products_id'], 'custom_style')) {
$display_products_style = '<br />' . TEXT_PRODUCTS_STYLE . $products_new->fields['custom_style'] . TEXT_STYLE . str_repeat('<br clear="all" />', substr(PRODUCT_NEW_LIST_STYLE, 3, 1));
} else {
$display_products_style = '';
}
[/FONT]
[FONT="Arial Black"]Table area code[/FONT][FONT="Courier New"]
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_MODEL_NAME') {
echo $display_products_model_name;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_STYLE') {
echo $display_products_style;
}
if ($disp_sort_order->fields['configuration_key'] == 'PRODUCT_NEW_LIST_STYLE_LABEL') {
echo $display_products_style_label;
}
[/FONT]
[FONT="Arial Black"]Failing code[/FONT][FONT="Courier New"]
if (PRODUCT_NEW_LIST_STYLE_LABEL != '0') {
zen_get_info_page($products_new->fields['products_id']);
zen_products_lookup($product['id'], 'custom_style');
if (empty($products_new->fields['custom_style'])) {
$display_products_style_label = '';
} else {
$display_products_style_label = zen_products_lookup($product['id'], 'details_size') . '<span style="text-transform:uppercase; font-size:0.8em">size </span>';
}
} else {
$display_products_style_label = '';
}
[/FONT]



