Jump to content

Smarty PHP help


ianhaney30

Recommended Posts

Hi 
 
I am working on a website that uses smarty tags and to be honest am really stuck as don't use smarty often 
 
 
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
Link to comment
https://forums.phpfreaks.com/topic/291370-smarty-php-help/
Share on other sites

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.  

Link to comment
https://forums.phpfreaks.com/topic/291370-smarty-php-help/#findComment-1492457
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.