Call Category Picture

Discussion in 'Templates, HTML, CSS, and Design Help' started by pickyourownpet.com, Feb 21, 2011.

  1. Developer 4.1.10


    Hello,

    I have a 2 Part Question. I am using the Promotional Category Text {$promo} and I need a little help.

    In the Browse.tpl, I am trying to place code to replace the {$promo} IF {$promo} is not null (I don't know the programming language). I have the proper CSS in place and I am really close. I need it to work like this:
    Code:
    {if isset($promo)}
    	<div class="displayhead">
    <div class="catpic">
    <img src="{$data[td].image}" />
    </div><div class="catdes">{$promo}
    </div></div>
    {/if}
    Now I am looking for the image source to actually be to Category Image that the customer is in, and this is not working either. I hope this makes sense. Thanks you!

    Click here to see what I mean and what I am looking for.

    Thank you!!
  2. Lhotch curmudgeon

  3. Thank You Larry for making me do the research! I have this so far and it works perfect except I cannot call the category image to save my life. Any other assistance would be great!

    Code:
    	{if $promo != ''}
    	<div class="displayhead">
    <div class="catpic">
    <img src="{$data[td].image}" />
    </div><div class="catdes">{$promo}
    </div></div>
    {/if}

    Thanks Again!
  4. Lhotch curmudgeon

    In order for you to "get" the category image it has to be available as a smarty variable ON the page currently being viewed.

    That being said, generally speaking it doesnt make any sense to have a variable defined on a page where it isnt being used. When viewing an ad or a list of ads in a category im guessing the category image isnt needed and thus isnt available.

    use the debug console to show you the variables that are available on the page where you want to display the category image, what do you see?
  5. I see a lot of nonsense- I understand (to a point) what is going on, though I don't necessarily understand what to pick from it and how to place it in the code I desire.

    I found the following:

    SELECT id,parent_id,name,slug,description,image,allowads,cLink,cKeywords,cPromo FROM class_categories WHERE slug='rottweiler' AND display<>'N'

    I assume this particular line is describing the category that I am in. How would I pick and choose out of these available variables? I suppose I am looking for something like the id or parent_id and the image?
  6. Lhotch curmudgeon

    in your code above you have....


    <img src="{$data[td].image}" />


    where did you come up with the smarty variable

    {$data[td].image}
  7. I randomly stole it from browse.tpl (knowing it would not necessarily work). It pulls the subcategory images, but I figured I could somehow work with it. if I use {$categoryid}, it will give me the id number.

    {$categoryid.image} does not work...


    I was reading this thread, but the poster did not post exactly how he created a category image variable in category.php. I think that is what I need.
  8. Lhotch curmudgeon

    You can waste an aweful lot of time randomly grabbing tidbits and hope to make them work but your best bet is to spend a little time to understand how smarty works because in the long run it will save you tons of time. Guessing your way through it more often than not makes a mess.

    use smarty debug to display the variables for the page your on. ONLY those variables displayed via debug on any given page will be available for use on that page. There is no category image variable on the page where you view listings. That leaves you a couple options, write a plugin to query the database to get the image OR embed php code to query the database to get the image. A plugin would be cleaner.
  9. Thank you for the help Larry. I appreciate it!

Share This Page