Forum Index >  glFusion >  glFusion Add-on, Plugin Support New Topic Post Reply
 evList - display categories
   |  Printable Version
By: Alex (offline)  Jul 08 2010 13:41 pm (Read 983 times)  
Alex

Hi all

I have a question about the evList Plugin center block.

How can I display for each event the categories to which it belongs?

Thanks

It's not who I am underneath... but what I do that defines me.


Forum Active Member
Active Member

Group Comfort
Level:
: +12

Registered: 05/18/09
Posts: 184
Location: Romania

Profile Email    
  Quote
By: Alex (offline)  Jul 09 2010 10:44 am  
Alex

Hi again

How can I make the {category_links} work in other thtml files? I would like to use the {category_links} in list_item.thtml to display for each event the categories.

Thanks

It's not who I am underneath... but what I do that defines me.


Forum Active Member
Active Member

Group Comfort
Level:
: +12

Registered: 05/18/09
Posts: 184
Location: Romania

Profile Email    
  Quote
By: lgarner (offline)  Jul 09 2010 15:11 pm  
lgarner

The template variables are populated by the code, so just adding one won't necessarily do anything. From what I can tell, the list_item.thml template is used by index.php when displaying the list. So, by borrowing some code from event.php, which does show the category list, we can make it work.

First, I created a new function to get the category list:

PHP Formatted Code
function EVLIST_getCatLinks($eid)
{
    global $_TABLES, $_CONF;

    $cresult = DB_query("SELECT id, name
            FROM {$_TABLES['evlist_categories']} tc
            LEFT JOIN {$_TABLES['evlist_lookup']} tl
                ON id = cid
            WHERE eid = '".DB_escapeString($eid)."'
            AND tl.status = '1'");
    $catcount = DB_numRows($cresult);
    if ($catcount >= 1) {
        $t = new Template($_CONF['path'] . 'plugins/evlist/templates/');
        $t->set_file('category_links', 'category_links.thtml');
        $t->set_var('catmore', $LANG_EVLIST03[23]);
        $i = 1;
        while ($C = DB_fetchArray($cresult)) {
            $catlink = '<a href="';
            $catlink .= COM_buildURL($_CONF['site_url'] .
                '/evlist/index.php?op=list' . $andrange . '&cat=' . $C['id']);
            $catlink .= '">' . COM_stripslashes($C['name']) . '</a>&nbsp;';
            if ($i < $catcount) {
                $catlink .= '|&nbsp;';
            }
            $t->set_var('category_link', $catlink, true);
            $i++;
        }
        $t->parse('categories', 'category_links');
        $retval = $t->finish($t->get_var('categories'));
    } else {
        $retval = '';
    }

    return $retval;

}


I just added it to the bottom of public_html/evlist/index.php for testing, but you'd want to put it in lib-custom.php so it doesn't get lost when you update glFusion.

Likewise, copy the list_item.thtml file to the custom subdirectory, and edit the copy to add {category_links} where you want it. This will also be protected from updates.

Now, the one piece that you'll have to maintain yourself. In index.php at about line 150, where the template variables are being set, you'll add one for category_links so it looks like this:

PHP Formatted Code
            $t->set_var(array(
                'title' => $titlelink,
                'date_summary' => $datesummary,
                'summary' => $summary,
                'more_link' => $morelink,
                'contact_link' => $contactlink,
                'block_title' => $block_title,
                'category_links' => EVLIST_getCatLinks($A['id']),
            ));


Forum Admin
Admin

Group Comfort
Level:
: +52

Registered: 06/10/08
Posts: 1912

Profile Email Website  
  Quote
By: Alex (offline)  Jul 18 2010 18:26 pm  
Alex

Thank you for your help, lgarner. It works.

Thanks again Smile

It's not who I am underneath... but what I do that defines me.


Forum Active Member
Active Member

Group Comfort
Level:
: +12

Registered: 05/18/09
Posts: 184
Location: Romania

Profile Email    
  Quote
New Topic Post Reply


 All times are CDT. The time is now 07:10 am.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic w/ New Post Sticky Topic w/ New Post
Locked Topic w/ New Post Locked Topic w/ New Post
View Anonymous Posts 
Able to Post 
HTML Allowed 
Censored Content