adding ad photo to modify listing table

Discussion in 'Customizations' started by EnergyFreak, May 8, 2010.

  1. EnergyFreak Customer

    Hey,

    I am trying to add a photo to the modifiy listing table on the user account. Basically I want to add the ad photo to the current table. I have added this to create the table header:

    Code:
    <th>{$smarty.const.LANG_PHOTO}</th>
    and so far no problem. But then when I add the actual code to go and get the photo from the database, it is not pulling anything, therefore it shows the nophoto.gif. But it should be pulling the actual photo since the ad does have a photo. This is the code I got from user favorites.tpl:

    Code:
    <td class="{cycle values="row1,row2" advance=false}"><a href="viewlisting.php?view={$entry.id}">{if $entry.image != ""}<img src="thumbs/small_{$entry.image}" />{else}<img src="images/nophotosmall.gif" border='0' />{/if}</a></td>
    This is the full code for the userbrowselisting.tpl that I am working with:

    Code:
    <table class="main" width="100%">
    	<tr>
    		<th>{$smarty.const.LANG_PHOTO}</th>
            <th>{$smarty.const.LANG_TITLE}</th>
    		<th>{$smarty.const.LANG_LISTING_ACTIVE}</th>
    		<th>{$smarty.const.LANG_LISTING_EXPIRATION}</th>
    		<th>{$smarty.const.LANG_LISTING_MODIFY}</th>
    		<th>{$smarty.const.LANG_LISTING_DELETE}</th>
    	</tr>
    	{if $results}
    		{foreach from=$results item="entry"}
    		<tr>
    		     <td class="{cycle values="row1,row2" advance=false}"><a href="viewlisting.php?view={$entry.id}">{if $entry.image != ""}<img src="thumbs/small_{$entry.image}" />{else}<img src="images/nophotosmall.gif" border='0' />{/if}</a></td>
                 <td class="{cycle values="row1,row2" advance=false}">{$entry.title}</td>
    		     <td class="{cycle values="row1,row2" advance=false}">
    		      {if $entry.expirationTime < $smarty.now}
    		     	{$smarty.const.LANG_EXPIRED}
    		     {elseif $entry.display == "Y"}
    		     	{$smarty.const.LANG_YES}
    		     {elseif $entry.oStatus == 3}
    		     	Pending Payment
    		     {else}
    		     	{$smarty.const.LANG_NO}
    		     {/if}
    		     </td>
    		     <td class="{cycle values="row1,row2" advance=false}">
    		     	{$entry.expiration|date_format:$dateformat}
    		     	{if $entry.oStatus == 3 || $entry.oStatus==4}
    		     	 
    		     	{elseif $entry.renew}
    		     		<br /><a href="userrenew.php?action=renew&listingid={$entry.id}&orderid={$entry.orderID}">{$smarty.const.LANG_LISTING_CLICK_TO_RENEW}</a>
    		     	{else}
    		     		<br /><a href="userrenew.php?action=renew&listingid={$entry.id}&orderid={$entry.orderID}">{$smarty.const.LANG_LISTING_UPGRADE}</a>
    		     	{/if}
    		     </td>
    		     {if $entry.oStatus==3 || $entry.oStatus==4}
    		     <td class="{cycle values="row1,row2" advance=false}"><input type="button" value="{$smarty.const.LANG_MAKE_PAYMENT}" onClick="MM_goToURL('parent','usercheckout.php?step=6&listingid={$entry.id}&productid={$entry.oProductID}');return document.MM_returnValue" /></td>
    		     {else}
    		     <td class="{cycle values="row1,row2" advance=false}"><input type="button" value="{$smarty.const.LANG_LISTING_MODIFY}" onClick="MM_goToURL('parent','usermodifylisting.php?view={$entry.id}');return document.MM_returnValue" /></td>
    		     {/if}
    		     <td class="{cycle values="row1,row2" advance=true}"><input type="button" value="{$smarty.const.LANG_LISTING_DELETE}" onClick="delrec('{$entry.id}')" /></td>
    		</tr>
    A supplied screenshot is attached to this post.

    Attached Files:

  2. Mike-N-Tosh Owner

    Try using the smarty {debug} to get the actual variables that are assigned to the template that you are working with. You need to understand that the variables assigned to any given template may be different and many times are different for the individual template files. You are using a variable that obviously isn't assigned to the template that you are working in.

    An FYI: to see what variables are given to any template or displayed page, place "{debug}" at the very top above everything else in the layout.tpl file of the template that you are using. Make sure that you turn off any pop up window blocker that you may have. If you are using the SEO module, you will also need to de-activate it. This built in smarty function will then pop up a separate window displaying all available variables for any page that you visit as well as which template file and script file is in use.
  3. EnergyFreak Customer

    This functions pulls the pictures from the database right?

    Code:
    {$entry.id}
    How can this differ from a template from another? I am using purple template and when I used debug on layout.tpl this is what I got:

    Code:
    SELECT title AS sitetitle, email, url, urls, keywords, description, version, mainTemplate, adminTemplate, notify,mainIndexCols,mainCatCols,mainSubCols,mainTakeOffline,mainTakeOfflineReason,mainEmailValidation,smtp,smtpHost,smtpUsername,smtpPassword,smtpPort,mailHTML,htmlEditor,removeTime,showTotal,template_title,template_logo FROM class_admin WHERE id=1
    SELECT cCurrencySymbol, cCurrencyDecimal, cCurrencyDecimalPlaces, cCurrencyThousands, cCurrencyAfter, cDateFormat, cAdminDateFormat, cLanguage, cAdminLanguage FROM class_currency_settings WHERE cID=1
    SELECT name, directory FROM class_modules WHERE state=3 ORDER BY mOrder, displayname
    SELECT * FROM class_users WHERE (username = '') AND (cookie = '') AND level=1
    I do not see how this can help me. I just want to pull the current ad picture from the database and show it as a thumbnail. Any other hints would be greatly appreciated.
  4. Mike-N-Tosh Owner

    You need to read the instructions for using the smarty {debug} as I posted, NOT the debug module. Those are completely different things! Furthermore {entry.ID} is NOT a function. It is a variable that is assigned to a template by a function. Functions are the processes used in the script, or the php. Which again I covered in my post. Any given function can assign a variable to a template, which is why and how it can and does vary from template to template.

    So when you actually use the smarty {debug} it will then give you a list of every single variable that is assigned to the template as well as other information which WILL give you the exact item that you are looking for.

    If you need further information regarding Smarty and the debug then please visit the online documentation for 68 Classifieds and/or visit the official smarty website.
  5. EnergyFreak Customer

    I finally figured how to use smarty function to debug my template, but I am still clueless as which variable pulls the ad photos from the database. This is what I got.

    PHP:
    Smarty Debug Console
    included templates 
    config files (load time in seconds)
    no templates included
    assigned template variables
    {$SCRIPT_NAME}    "/index.php"
    {$allowedTags}    "<b><strong><p>"
    {$body}    "home.tpl"
    {$canSaveFavorites}    "Y"
    {$checkoutDisDesc}    "Y"
    {$checkoutDisPrice}    "Y"
    {$checkoutDisShortDesc}    "Y"
    {$checkoutDisURL}    "Y"
    {$checkoutManuallyApprove}    "N"
    {$checkoutModifyStatus}    "N"
    {$checkoutNotification}    "Y"
    {$checkoutRequireDesc}    "N"
    {$checkoutRequirePrice}    "Y"
    {$checkoutRequireShortDesc}    "N"
    {$cols}    "2"
    {$currency_symbol}    "€"
    {$data}    Array (1)
    => Array (11)
      
    id => "1"
      
    parent_id => "0"
      
    name => "test"
      
    slug => "test"
      
    description => ""
      
    image => "templates/purple/images/folder.gif"
      
    allowads => "Y"
      
    cLink => ""
      
    start_link => "<a href="category.php?cat=test" title..."
      
    subcats => ""
      
    total => "7"
    {$dateformat}    "%B %e, %Y"
    {$headtitle}    "68 Classifieds"
    {$lastDate}    "2010-05-12"
    {$newpms}    null
    {$pPageContent}    "<div style="background-color:#ffc709;..."
    {$pmon}    "Y"
    {$querycounter}    12
    {$queryhistory}    Array (12)
    => "SELECT title AS sitetitle, email, url..."
    => "SELECT cCurrencySymbol, cCurrencyDeci..."
    => "SELECT name, directory FROM class_mod..."
    => "SELECT turnedon, max FROM class_setti..."
    => "SELECT uBanned,uAllowContact,uAllowEm..."
    => "SELECT pageID, pPageTitle, pURI FROM ..."
    => "SELECT checkoutNotification,checkoutM..."
    => "SELECT pPageContent FROM class_pages ..."
    => "SELECT id,parent_id,name,slug,descrip..."
    => "SELECT id,name,slug,image,cLink FROM ..."
    10 => "SELECT id FROM class_categories WHERE..."
    11 => "SELECT COUNT(*) AS size FROM class_li..."
    {$renewal}    "Y"
    {$renewalDays}    "7"
    {$script_name}    "index.php"
    {$sitedescription}    "Your site description"
    {$sitekeywords}    "keywords, go, here"
    {$sitetitle}    "68 Classifieds"
    {$tc_jcarousel}    "on"
    {$template_description}    "Your site description"
    {$template_logo}    ""
    {$template_title}    "68 Classifieds"
    {$templatecodes}    "on"
    {$templatepages}    Array (0)
    {
    $title}    "68 Classifieds"
    assigned config file variables (outer template scope)
    {
    #files#}    Array (0)
    {#vars#}    Array (0)
  6. Mike-N-Tosh Owner

    You need to look at the smarty window for the template page you want the variables for. You posted the smarty window from your home page. Notice how it says script name /index.php and body is home.tpl? You said you were wanting to add the photo on the users account page. Visit that page with the {debug} active to see the variables for that page.
  7. EnergyFreak Customer

    Oh okay thanks. This is what I found on new ads page where there are ads with photos under the {$results}

    PHP:
    Array (7)
    => Array (30)
      
    id => "10"
      
    owner => "1"
      
    title => "tetststs"
      
    featured => "N"
      
    section => "1"
      
    shortDescription => "test"
      
    description => "ttast"
      
    price => "123.00"
      
    dateadded => "2010-05-09 03:47:55"
      
    expiration => "2011-05-19 03:47:55"
      
    display => "Y"
      
    pHighlighted => "N"
      
    pBold => "N"
      
    hitcount => "2"
      
    url => ""
      
    username => "*****"
      
    state => "none"
      
    city => "Belmont"
      
    country => "Afghanistan"
      
    extra => "test"
      
    extra2 => "test"
      
    extra3 => "test"
      
    sTitle => ""
      
    sDescription => ""
      
    sImage => ""
      
    status => "Y"
      
    image => "despicable_me_111680x1050.jpg"
      
    class => ""
      
    link => "viewlisting.php?view=10"
      
    custom => ""
    I believe it might be the "sImage" what would I do with this variable?
  8. seymourjames All Hands On Deck

    It says simage variable appears to be empty.

    Just take the main image entry.image and scale it with your thumbnail dimensions.

Share This Page