Template with pulling image data through different file other than download.php:
<img src="cat.php?img={vb:var cid}" height="50">
Keep in mind the var $cid is pulled in the download.php file while the image pull is a separate file but right now I want to attempt to combine the files into one.
File:
if ($vbulletin->options['bfc_download_active']){
$img = $_REQUEST['img'];
Code that is pulling the data for the $cid variable:
$sql = $vbulletin->db->query_read("SELECT * FROM `" . TABLE_PREFIX . "download_cats` WHERE cat_active = '1'");
Where do you register $cid for use in the template in the second chunk of code?
while ($row = $db->fetch_array($sql))
{
$cid = $row['catid'];
Is that what you mean by registered? Or are you talking about cleaned?
You need to register variables to make them available in templates:
http://www.vbulletin.org/forum/showthread.php?t=228078
I thought you knew all that, since you're already doing it:
$catb = vB_Template::create('bfc_download_cat_bit');
$catb->register('cat_bit', $cat_bit);
$cat_bit .= $catb->render();
You need to do the same as in the second line for $catb for $cid.
$cid is not a template or do all variables you use no matter if they are a template or not need to be registered?
I knew about templates but was unaware of having to do it for data variables such as $cid.
bfc_download_cat_bit is the template. You create it by calling the vB_Template:create method, and then you need to register every variable you want to use inside that template, no matter what's saved inside that variable. It can contain a rendered template, or it can contain just a simple boolean false or true. That does not matter, you need to register it to be able to use it. Then, in the next step, you render the template.
Ok I can't figure out why this:
</td> </td></tr><tr>
Is displaying above my results when it should only use those if its starting a new row and ending another.
Just a quick note on security :)
$img = $_REQUEST['img'];
Should be cleaned as you are using it here:
$result = $db->query_read("SELECT cat_icon,cat_type FROM download_cats WHERE catid=" . $img);
Thanks for pointing that out, I was actually starting to think I needed to clean it.