Category ID in viewlisting.tpl

Discussion in 'Customizations' started by pipelin, Dec 29, 2009.

  1. pipelin Customer

    What version of 68 Classifieds are you running?
    Example: V4.1.6 developre

    What template are you using?


    Please describe in detail the issue you are having:[/]

    Someone Know how to get category Id in viewlisting.tpl?
  2. Lhotch curmudgeon

    if you use smarty debug console you should see the variable section which should correspond to your categoryid.
  3. pipelin Customer

    Thanks Larry,

    I already did it and I only found the variable $categoryname, I also tried to create a plugin:

    PHP:

    function smarty_function_categoryid($params, &$smarty)
    {
        global 
    $db;
        
        
    $catname '';
        foreach (
    $params as $_key=>$_value
        {
            switch (
    $_key
            {
                case 
    'catname':
                $
    $_key $_value;
                    break;
            }
        }
        
            
    $sSQL "SELECT id FROM ".PREFIX."categories WHERE name=".$catname
            
    $result=$db->query($sSQL);
            if(
    $result->isError()) 
            {
                return 
    false;
            }
            if(
    $result->size()>0)
            {
                
    $rs=$result->fetch();
                
    $catid $rs['id'];
            }
            
    $result->freeResult();
            return 
    $catid;
        
    }
    But I got this error:

    Notice: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' Collectibles' at line 1 SQL: SELECT id FROM class_torcategories WHERE name=Art, Collectibles
  4. Eric Barnes Guest

    On viewlisting.tpl it is {$section} for the category id.
  5. pipelin Customer

    Thanks Eric,

    It works perfect.
  6. Lhotch curmudgeon

    Thats exactly what I said in my first reply to you.
  7. pipelin Customer

    Sorry Larry I didn't get you.

    I'm trying to do this.

    if the Ad is featured
    show something

    Someone know the variable featured in viewlisting.tpl
  8. Lhotch curmudgeon

    once again, all the answers are in the debug output. {$featured}
  9. pipelin Customer

    Thanks Larry

Share This Page