ianhaney30 Posted September 30, 2014 Share Posted September 30, 2014 Hi I am working on a website that uses smarty tags and to be honest am really stuck as don't use smarty often The site is http://irhwebsites.com/sites/zacs-car-site/index.php I want to have instead of featured listings have recently added and think I got the listings displayed but it only displays listings with images where as I would like it to display listings with and without images and also have it display random listings not just one below are the links to pastebin with the coding for that section functions.php function getRandomImage() { global $use_listing_approval; $limit = 3; $approved = ''; if ($use_listing_approval) { if (!isset($_SESSION["admin"])) { if (isset($_SESSION["seller"])) { $approved = ""; } else { $approved = "listings.approved = 1 AND listimages.approved = 1 AND "; } } } //$sql = "SELECT * FROM listimages, listings WHERE $approved listings.id = listimages.listingid AND listings.sold !=1 AND listimages.mainimage = 1 ORDER BY RAND() LIMIT $limit"; $sql = "SELECT * FROM listimages, listings WHERE $approved listings.id = listimages.listingid AND listings.sold !=1 AND listimages.mainimage = 1 ORDER BY added_on DESC LIMIT $limit"; $res = sqlQuery($sql); if(sqlErrorReturn()) sqlDebug(__FILE__,__LINE__,sqlErrorReturn()); $c=0; while ($a_row = sqlFetchArray($res)) { $records[$c]["ad_title"] = $a_row["ad_title"]; $records[$c]["make"] = $a_row["make"]; $records[$c]["model"] = $a_row["model"]; $records[$c]["listingid"] = $a_row["listingid"]; $records[$c]["imagepath"] = $a_row["imagepath"]; $records[$c]["imagethumbpath"] = $a_row["imagethumbpath"]; //Price_eingef�gt_09_02_09 $records[$c]["price"] = $a_row["price"]; ++$c; } if (isset($records)) return $records; return false; } index.tpl file {if $records} <div class="smallrightlist"> <h2 class="subhead">{$smarty.const.INDEX_FEATURED}</h2> {foreach item="image" from=$records} <p> {if $use_fancy_urls} <a href="listings/view/{$image.make|strip:"-"}/{$image.model|strip:"-"}/{$image.listingid}/"> <img src="{$image.imagethumbpath}" title="{$smarty.const.IMAGE} {counter}" alt="{$smarty.const.IMAGE} {counter}" /></a> {else} <a href="listings.php?make={$image.make|strip:"-"}&model={$image.model|strip:"-"}&id={$image.listingid}"><img src="{$image.imagethumbpath}" title="{$smarty.const.IMAGE} {counter}" alt="{$smarty.const.IMAGE} {counter}" /></a> {/if} <br />{$image.ad_title} </p> {/foreach} </div> {/if} index.php file //get random images for the frontpage $smarty->assign("records",getRandomImage()); I just don't get it, please help am well stuck Thank you Kind regards Ian Quote Link to comment Share on other sites More sharing options...
gizmola Posted September 30, 2014 Share Posted September 30, 2014 Smarty is primarily HTML markup with some logic blocks. Data gets injected and the logic blocks work and you get output. What else is there to it that is confusing? They have solid documentation as well. You need to clarify exactly what you are "stuck" on. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.