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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.