Why is this code not displaying properly on the fronend? - wordpress

I have created this from advanced custom fields and would like to display a restaurant menu in rows and column. The first three columns are displaying as intended but for unknown reason the last column does not display within the table. As shown on the attached image, the last column is showing above the table header and I am not sure what's wrong with the code.
[
`
<table>
<thead>
<tr>
<td class="photo">Photo</td>
<td class="menu_name">Menu Item</td>
<td class="descriptions">Descriptions</td>
<td class="price">Price</td>
</tr>
</thead>
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
</td><?php the_sub_field( 'price' ); ?></td>
<?php endwhile; ?>
</tr>
</table>
<?php else : ?>
<?php // no rows found ?>
<?php endif; ?>`

you have typo error on the opening tag of the last td
**</td>**<?php the_sub_field( 'price' ); ?></td>
should be < td > without /
Hope it works! :)

Also, the tr tag is opening in while loop. So it should close in the while loop. Please check below code:
<?php while ( have_rows( 'restaurant_menu_items' ) ) : the_row(); ?>
<tr>
<td><?php $photo = get_sub_field( 'photo' ); ?>
<?php $size = 'thumbnail'; ?>
<?php if ( $photo ) : ?>
<?php echo wp_get_attachment_image( $photo, $size ); ?>
<?php endif; ?> </td>
<td> <?php the_sub_field( 'menu_name' ); ?></td>
<td><?php the_sub_field( 'descriptions' ); ?></td>
<td><?php the_sub_field( 'price' ); ?></td>
</tr>
<?php endwhile; ?>

Related

Why does the Subtotal/Shipping/Total display twice?

This is my review-order.php table for woocommerce checkout
I cant seem to figure out why the last section with subtotal/shipping/total Displays Twice
I assume it must be something wrong with the code in second table?
Can i also add a column to first table to display product thumbnail? I have a snippet in my functions.php to add thumbnail here but i would prefer it was in a column of its own to the left of all the product info
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
</table>
<table>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
Not sure if this is it but i noticed there are two table tags, one with tbody and the next with tfoot... wondering if upadting to a single table does anything:
<?php
defined( 'ABSPATH' ) || exit;
?>
<table class="shop_table woocommerce-checkout-review-order-table">
<tbody>
<?php
do_action( 'woocommerce_review_order_before_cart_contents' );
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
if ( $_product && $_product->exists() && $cart_item['quantity'] > 0 && apply_filters( 'woocommerce_checkout_cart_item_visible', true, $cart_item, $cart_item_key ) ) {
?>
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $cart_item, $cart_item_key ) ); ?>">
<td class="product-name">
<?php echo apply_filters( 'woocommerce_cart_item_name', $_product->get_name(), $cart_item, $cart_item_key ) . ' '; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo wc_get_formatted_cart_item_data( $cart_item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<?php echo apply_filters( 'woocommerce_checkout_cart_item_quantity', ' <strong class="product-quantity">' . sprintf( '× %s', $cart_item['quantity'] ) . '</strong>', $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
<br>
<?php echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $_product, $cart_item['quantity'] ), $cart_item, $cart_item_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</td>
</tr>
<?php
}
}
do_action( 'woocommerce_review_order_after_cart_contents' );
?>
</tbody>
<tfoot>
<tr class="cart-subtotal">
<th><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>
</tr>
<?php foreach ( WC()->cart->get_coupons() as $code => $coupon ) : ?>
<tr class="cart-discount coupon-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php wc_cart_totals_coupon_label( $coupon ); ?></th>
<td><?php wc_cart_totals_coupon_html( $coupon ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( WC()->cart->needs_shipping() && WC()->cart->show_shipping() ) : ?>
<?php do_action( 'woocommerce_review_order_before_shipping' ); ?>
<?php wc_cart_totals_shipping_html(); ?>
<?php do_action( 'woocommerce_review_order_after_shipping' ); ?>
<?php endif; ?>
<?php foreach ( WC()->cart->get_fees() as $fee ) : ?>
<tr class="fee">
<th><?php echo esc_html( $fee->name ); ?></th>
<td><?php wc_cart_totals_fee_html( $fee ); ?></td>
</tr>
<?php endforeach; ?>
<?php if ( wc_tax_enabled() && ! WC()->cart->display_prices_including_tax() ) : ?>
<?php if ( 'itemized' === get_option( 'woocommerce_tax_total_display' ) ) : ?>
<?php foreach ( WC()->cart->get_tax_totals() as $code => $tax ) : // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited ?>
<tr class="tax-rate tax-rate-<?php echo esc_attr( sanitize_title( $code ) ); ?>">
<th><?php echo esc_html( $tax->label ); ?></th>
<td><?php echo wp_kses_post( $tax->formatted_amount ); ?></td>
</tr>
<?php endforeach; ?>
<?php else : ?>
<tr class="tax-total">
<th><?php echo esc_html( WC()->countries->tax_or_vat() ); ?></th>
<td><?php wc_cart_totals_taxes_total_html(); ?></td>
</tr>
<?php endif; ?>
<?php endif; ?>
<?php do_action( 'woocommerce_review_order_before_order_total' ); ?>
<tr class="order-total">
<th><?php esc_html_e( 'Total', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_order_total_html(); ?></td>
</tr>
<?php do_action( 'woocommerce_review_order_after_order_total' ); ?>
</tfoot>
</table>
My thought is there may be some js code somewhere adding the second one since there are two tables. Im still "debugging" to see if anything else jumps out at me.

Return Posts as single table

query_posts( array(
'post_type' => 'ts_result',
'meta_query' => array(
array(
'key' => '_ts_student_class',
'value' => $exam_reg,
'compare' => '='
),
array(
'key' => '_ts_school_term',
'value' => $exam_term,
),
array(
'key' => '_ts_school_year',
'value' => $exam_year,
)
),
'posts_per_page' => 100
)
);
?>
<table style="border:1px solid black" cellpadding="1.5" cellspacing="5">
<style type="text/css" media="print">
table{
border-collapse:collapse;
}
</style>
<tbody>
<tr>
<th><strong>NAME\SUBJECT</strong></th>
<th><strong>English Studies</strong></th>
<th align='center'><strong>Mathematics</strong></th>
<th align='center'><strong>CCA</strong></th>
<th align='center'><strong>Yoruba Language</strong></th>
<th align='center'><strong>French</strong></th>
<th align='center'><strong>Business Education</strong></th>
</tr>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$subject_english_studies_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_english_studies_exam_total',true );
$subject_maths_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_maths_exam_total',true );
$subject_creative_arts_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_creative_arts_exam_total',true );
$subject_yoruba_lang_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_yoruba_lang_exam_total',true );
$subject_french_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_french_exam_total',true );
$subject_business_edu_exam_total= get_post_meta(
get_the_ID(),'_ts_subject_business_edu_exam_total',true );
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php echo $subject_english_studies_exam_total ;?></td>
<td><?php echo $subject_maths_exam_total ;?></td>
<td><?php echo $subject_creative_arts_exam_total ;?></td>
<td><?php echo $subject_yoruba_lang_exam_total ;?></td>
<td><?php echo $subject_french_exam_total ;?></td>
<td><?php echo $subject_business_edu_exam_total ;?></td>
</tr>
</tbody>
</table>
the above query in Wordpress returns the following:
What I seek to achieve is a table with one header and the other post content as rows. presently only the first post values is being formatted properly as table rows.
You have done small mistake by not closing the while loop before the </tbody>. Code will be like the following :
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<tr>
<td><?php the_title(); ?></td>
<td><?php echo $subject_english_studies_exam_total ;?></td>
<td><?php echo $subject_maths_exam_total ;?></td>
<td><?php echo $subject_creative_arts_exam_total ;?></td>
<td><?php echo $subject_yoruba_lang_exam_total ;?></td>
<td><?php echo $subject_french_exam_total ;?></td>
<td><?php echo $subject_business_edu_exam_total ;?></td>
</tr>
<?php endwhile;endif; ?>
Hope it helps you.

Allow users to search for other users in Wordpress Frontend

I have a plugin that I've created within my site, which just shows one page where I'm calling all users and then some specific information about those users.
Would it be possible to allow users to search for other existing users from the front end of the site?
This is the kind of thing I've got going on at the moment, I haven't been able to find any kind of search of this sort of thing, so if anyone could point me in the right direction it's be very much appreciated,
I haven't included any code as it's not that relevant really, but I can include it if needs be,
Thanks in advance!
http://focusedlearning.hcrlaw.com/courses-admin/
<?php $total_users = count_users();
$total_users = $total_users['total_users'];
$paged = get_query_var('paged');
$number = 20;?>
<?php
$args = array(
'order' => 'ASC',
'orderby' => 'display_name',
'count_total' => 'true',
'role' => 'subscriber',
'offset' => $paged ? ($paged) * $number : 0,
'number' => $number,
);?>
<?php
$blogusers = get_users($args);?>
<?php // Array of WP_User objects.
foreach ( $blogusers as $user ) {?>
<?php $userId = $user->ID;?>
<?php echo '<input type="text" value="' . esc_html( $user->display_name ) . '">';?>
<div id="content">
<h2>Completed Courses</h2>
<!-- COMPLIANCE-->
<?php
$post_args = array(
'post_type' => 'tribe_events',
'eventDisplay'=>'custom',
'start_date' => date( 'Y-m-d H:i:s', strtotime( '-365 days' ) ),
'tax_query' => array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'slug',
'terms' => 'compliance',
),
),
'meta_query' => array(
array(
'key' => 'associated_people',
'value' => '"' . $userid . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
'compare' => 'LIKE'
)
)
); ?>
<!-- MEMBERSHIP A -->
<?php if( rcp_is_active() && 2 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP A -->
<!-- MEMBERSHIP B -->
<?php if( rcp_is_active() && 3 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP B -->
<!-- MEMBERSHIP C -->
<?php if( rcp_is_active() && 4 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP C -->
<!-- MEMBERSHIP D -->
<?php if( rcp_is_active() && 5 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP D -->
<!-- MEMBERSHIP E -->
<?php if( rcp_is_active() && 6 == rcp_get_subscription_id() ) : ?>
<?php
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<tr>
<td>Compliance</td>
</tr>
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
?>
<tr>
<td><?php the_title(); ?></td>
<td><?php the_field('cpd_credits'); ?></td>
</tr>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<?php
$total_credit = 0;
$post_list = new wp_query( $post_args ); ?>
<table style="width:100%">
<?php
if( $post_list->have_posts() ) : while( $post_list->have_posts() ) : $post_list->the_post();
$cur_credit = get_field('cpd_credits');
$total_credit += $cur_credit;
?>
<?php endwhile; else : ?>
<?php endif; wp_reset_query(); ?>
<tr>
<td <?php if($total_credit >= 2): ?> style="background-color:#009137;" <?php endif; ?> <?php if($total_credit < 2): ?> style="background-color:#f50c1a;" <?php endif; ?>>
Total: <?php echo $total_credit;?> of 2 in the last 12 months
</td>
</tr>
</table>
<?php endif; ?>
<!-- END OF MEMBERSHIP E -->
<!-- END OF COMPLIANCE-->

ACF Repeater display row number

Looking to display the individual number of each repeater row. So for example, the first row will display "1" and the second row will display "2".
I found this from Elliot,
<?php echo count( get_field('repeater_field') );?>
which counts how many rows there are in total. But I need the individual number next to each.
Thanks
I would suggest taking a look at Elliot's answer here:
http://support.advancedcustomfields.com/forums/topic/getting-instance-and-sort-of-id-of-repeater-field/
You would want to set up a counter variable ( $i ) and then add 1 to $i inside the loop.
<?php if( have_rows('repeater_field') ): $i = 0; ?>
<div class="repeater_loop">
<?php while( have_rows('repeater_field') ): the_row(); $i++; ?>
<p>This is row number <?php echo $i; ?>.</p>
<!-- call your sub_fields as needed -->
<?php endwhile; ?>
</div>
<?php endif; ?>
This would output a div with a paragraph tag that displays your row number.
<?php if( have_rows('tabel_produse_profit') ): $i = 0; ?>
<table width="100%" class="tab">
<tr>
<td>Nr.</td>
<td>Imagine</td>
<td>Nume</td>
<td>Evaluare</td>
<td>Verificati pretul</td>
</tr>
<?php while( have_rows('tabel_produse_profit') ): the_row(); $i++;
// vars
$image = get_sub_field('tabel_imagine_produs');
$link = get_sub_field('tabel_link_profit');
$titlu = get_sub_field('tabel_titlu_profit');
$evaluare = get_sub_field('tabel_evaluare');
$count = count(get_field('tabel_produse_profit'));
?>
<tr>
<td class="row1">
<?php echo $i; ?>
<?php if( $count ): ?>
<div class="rowc"> din <?php echo $count; ?></div>
<?php endif; ?>
</td>
<td class="row2">
<?php if( $image ): ?>
<img class="imag" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" />
<?php endif; ?>
</td>
<td class="row3">
<?php if( $titlu ): ?>
<h2><?php echo $titlu; ?></h2>
<?php endif; ?>
</td>
<td class="row4">
<?php if( $evaluare ): ?>
<div class="eva"><?php echo $evaluare; ?></div>
<?php endif; ?>
</td>
<td class="row5">
<?php if( $link ): ?>
<a class="ver" href="<?php echo $link; ?>">VERIFICAȚI PREȚUL</a>
<div class="mag">pe emag.ro</div>
<?php endif; ?>
</td>
<?php echo $content; ?>
</tr>
<?php endwhile; ?>
</table>
<?php endif; ?>
There is get_row_index() already available to use.

(Magento) Display product list

How to display products in list?
Replace the whole code of list.phtml to this...
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<table id="itemtable" style="width:100%;">
<thead><tr><th>Name</th><th>Short description</th><th>Brand</th><th>Price With Tax</th><th>Price Without Tax</th><th>Add To Cart</th></tr></thead>
<tbody>
<?php foreach ($_productCollection as $_product): ?>
<tr class="item<?php if( ++$_iterator == sizeof($_productCollection) ): ?> last<?php endif; ?>">
<td><?php $_productNameStripped = $this->stripTags($_product->getName(), null, true); ?><?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></td>
<td><?php echo $_product->getShortDescription(); ?></td>
<td>brand</td>
<td><?php
$_priceIncludingTax = Mage::helper('tax')->getPrice($_product, $_product->getPrice(), true, null, null, null, null, false);
echo $_priceIncludingTaxWithCurrency = Mage::helper('core')->currency($_priceIncludingTax); ?></td>
<td><?php
$_priceExcludingTax = Mage::helper('tax')->getPrice($_product, $_product->getPrice(), false, null, null, null, null, false);
echo $_priceExcludingTaxWithCurrency = Mage::helper('core')->currency($_priceExcludingTax); ?></td>
<td>
<?php if($_product->isSaleable() && !$_product->canConfigure()): ?>
<form action="<?php echo $this->getAddToCartUrl($_product) ?>" method="post" id="product_addtocart_form_<?php echo $_product->getId(); ?>"><input name="qty" type="text" class="input-text qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" /><button class="form-button" onclick="productAddToCartForm_<?php echo $_product->getId(); ?>.submit()"><span><?php echo $this->__('Add to Cart'); ?></span></button></form>
<script type="text/javascript"> var productAddToCartForm_<?php echo $_product->getId(); ?> = new VarienForm('product_addtocart_form_<?php echo $_product->getId(); ?>'); productAddToCartForm_<?php echo $_product->getId(); ?>.submit = function(){ if (this.validator.validate()) { this.form.submit(); } }.bind(productAddToCartForm_<?php echo $_product->getId(); ?>);</script>
<?php endif;?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateList('products-list', 'none-recursive')</script>
<?php endif; ?>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
</div>
<?php endif; ?>
<?php
//set product collection on after blocks
$_afterChildren = $this->getChild('after')->getSortedChildren();
foreach($_afterChildren as $_afterChildName):
$_afterChild = $this->getChild('after')->getChild($_afterChildName);
$_afterChild->setProductCollection($_productCollection);
?>
<?php echo $_afterChild->toHtml(); ?>
<?php endforeach; ?>
<style>
#itemtable th{ font-weight:bold!important;text-align:center!important;}
#itemtable tr{ height:50px!important;}
#itemtable tr td{ text-align:center!important;}
</style>
Let me know if you have any query...

Resources