Kurtis Houser Posted January 13, 2016 at 10:41 PM Share Posted January 13, 2016 at 10:41 PM (edited) I've created a custom widget for use on Facebook using the listings_tableview.thtml file. See attached screenshot. I would like to provide users with the option of disabling the Ratings column. However, since it's now a table I need to check the 'Show User Rating' setting so I can prevent the column from displaying if it's set to 'No.' Here's a link to the FB tab page as well as the code. https://www.facebook.com/itasteit/app/538926496274517/ <?php /** * JReviews - Reviews Extension * Copyright (C) 2010-2015 ClickFWD LLC * This is not free software, do not distribute it. * For licencing information visit https://www.jreviews.com * or contact [email protected] **/ defined( 'MVC_FRAMEWORK') or die( 'Direct Access to this location is not allowed.' ); // Custom fields that will be displayed in columns, uncomment the line below and replace field names in the array $columnFields = array('jr_cheesemilktype'=>'Milk', 'jr_cheesemilktreatment'=>'Treatment'); /********************************************************************************** * CONFIGURATION AND SETUP **********************************************************************************/ // Make all urls absolute $Html->abs_url = true; extract($config); $showfields = explode(",", $showfields); /** * Figure out what the 'read more' link should look like based on filters */ $read_more_url = $WidgetRoutes->readMoreUrl($category, $config); /********************************************************************************** * EDIT HTML BELOW THIS LINE **********************************************************************************/?> <div class="jr-page jrPage jrListings jrTableview"> <?php if(!empty($listings)):?> <div class="jrTableGrid jrDataList jrResults"> <div class="jrRow jrDataListHeader"> <div class="jrCol jrTableColumnThumbnail"></div> <div class="jrCol jrTableColumnMain"><?php __t("Details");?></div> <?php if(isset($columnFields)):?> <?php foreach($columnFields as $fieldName => $fieldLabel):?> <div class="jrCol jrTableColumnField"><?php echo $fieldLabel; ?></div> <?php endforeach;?> <?php endif;?> <div class="jrCol jrTableColumnRatings"><?php __t("Ratings");?></div> </div> <?php $i = 2; $j = 0; foreach($listings AS $listing): $i = $i == 2 ? 1 : 2; $j++;?> <?php /*************************************************************** ************ SET CONFIG OVERRIDES FOR EACH LISTING ************ ***************************************************************/ $mainMediaThumb = $Media->thumb(Sanitize::getVar($listing,'MainMedia'),array('listing'=>$listing,'thumbnailer'=>'api','size'=>$tnsize,'mode'=>$tnmode,'css_size'=>true)); $featured = Sanitize::getInt($listing['Listing'],'featured') ? ' jrFeatured' : ''; $size = explode('x',$tnsize); ?> <div class="jrRow"> <div class="jrCol jrTableColumnThumbnail" style="width: <?php echo $size[0]; ?>px"> <?php if($mainMediaThumb):?> <div class="jrListingThumbnail"> <a href="<?php echo $CustomFields->field('jr_productpage',$listing, false, false);?>"><?php echo $mainMediaThumb;?></a> </div> <?php endif;?> </div> <div class="jr-listing-outer jrCol jrTableColumnMain"> <div class="jrContentTitle"> <a href="<?php echo $CustomFields->field('jr_productpage',$listing, false, false);?>"><?php echo $CustomFields->field('jr_productname',$listing);?></a> </div> <?php if($summary && ($summary_text = Sanitize::getString($listing['Listing'],'description')) != ''):?> <?php /* SUMMARY */ ?> <div class="jrListingSummary"> <?php echo $Text->truncateWords($summary_text,$summary);?> </div> <?php endif;?> </div> <?php if(isset($columnFields)):?> <?php foreach($columnFields as $fieldName => $fieldLabel):?> <div class="jrCol jrTableColumnField"><?php echo $CustomFields->field($fieldName, $listing, false, false); ?></div> <?php endforeach;?> <?php endif;?> <div class="jrCol jrTableColumnRatings"> <?php /* OVERALL RATINGS */ ?> <?php echo $Rating->overallRatings($listing, 'module'); ?> <p class="jrButton"><?php echo $Html->sefLink("Write a review",$listing['Listing']['url']);?></p> </div> </div> <?php endforeach;?> </div> <div class="jrClear"></div> <?php endif;?> </div> <div class="jrClear"></div> <?php if($read_more_url != ''):?> <h4 style="float:right;">Powered by <a href="http://www.itasteit.com">iTasteIt.com</a>!</h4> <a class="jrButton" href="https://www.itasteit.com/producer/bellwether-farms"> <?php __t("Rate our products!");?> </a> <?php endif;?> Edited January 13, 2016 at 10:42 PM by Kurtis Houser Link to comment
Alejandro Posted January 13, 2016 at 10:56 PM Share Posted January 13, 2016 at 10:56 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Kurtis Houser Posted January 13, 2016 at 11:21 PM Author Share Posted January 13, 2016 at 11:21 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Alejandro Posted January 13, 2016 at 11:35 PM Share Posted January 13, 2016 at 11:35 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Kurtis Houser Posted February 12, 2016 at 04:39 PM Author Share Posted February 12, 2016 at 04:39 PM This section is only visible with a valid subscription. If you have a valid subscription, please login. Link to comment
Recommended Posts