Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2006
    Posts
    133
    Plugin Contributions
    0

    Default product listing: combine and output labels before combined data values

    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:
    1. model name | style » iPod | Shuffle
    2. 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]
    Last edited by molywerks; 29 Jun 2008 at 10:49 PM. Reason: fixed label typo

 

 

Similar Threads

  1. Altering Product Listing Output
    By lefthome in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 8 Apr 2008, 03:46 PM
  2. align product listing headings and data?
    By Lisa in Vermont in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 10 Aug 2007, 09:26 PM
  3. Product listing - combine 2 columns?
    By lismith in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 3 Aug 2007, 03:08 PM
  4. Dropdown names and values, editin html output
    By mrmarcus66 in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 20 Dec 2006, 11:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg