View Full Version : Correct code for plugin / vba variable usage?
PhilMcKrackon
04-20-2008, 10:00 PM
I'm working on getting a thumbnail display to work in the adv_links_linkbit template. All my thumbnail names are the link id and '_t.jpg' appended to them. I have the template edited and is functioning as I want but I can't get the plugin I made to evaluate correctly. The plugin is:
$show['thumb_exists'] = file_exists('/home/mesing/public_html/links/link_images/14_t.jpg');
The code evaluates true because the file 14_t.jpg exists and then evaluates false when I remove the image but what is the correct syntax to have the file name use the link id specified by $link[linkid] instead of the number 14? Is this even possible in a plugin? I hope I'm just tired and am missing some thing simple.
Thanks,
Brian
04-21-2008, 01:06 PM
You would use this code to replace 14 with the linkid.
$show['thumb_exists'] = file_exists('/home/mesing/public_html/links/link_images/' . $link['linkid'] . '_t.jpg');
vBa Links does not currently have any plugins though, so you would have to edit your forum/includes/functions_vba_links_cats.php file and add the code within the construct_linkbits() function.
PhilMcKrackon
04-21-2008, 01:35 PM
Thanks Brian, I had tried that before and the code always evaluated as false even though the code that was original evaluates as true. I just did try a copy of what you posted to make sure I didn't have a typo and the code still evaluates false. I'm beginning to think that the variable $link[] cannot be used in a plugin. Is there anyway to see what a variable is in VB? I have looked all over the CP to see if there was some way of monitoring them while code was running.
vBa Links does not currently have any plugins though, so you would have to edit your forum/includes/functions_vba_links_cats.php file and add the code within the construct_linkbits() function.For testing I applied the plugin to the 'global_start' hook location and this code in 'adv_links_linkbit'
<if condition="$show['thumb_exists']">
<img src="/links/link_images/$link[linkid]_t.jpg"" border="1" onload="if (this.width>50) this.border=1; this.alt='$link[name]';"></a>
<else />
<img src="/links/link_images/no_thumb.jpg"" border="10" onload="if (this.width>50) this.border=1; this.alt='$link[name]';"></a>
</if>works as long as I use the code for the plugin I posted. As long as I edit this '/home/mesing/public_html/links/link_images/14_t.jpg' in the plugin to 13_t.jpg or 12_t.jpg... The thumbnail shows for the link and all the links with out a thumbnail use the default thumbnail. It is only when I edit the plugin to reference the linkid that the plugin does not evaluate.
Maybe I'm just not understanding this but I do appreciate the help.
Brian
04-21-2008, 01:40 PM
You cannot use a plugin for this. You would have to edit your forum/includes/functions_vba_links_cats.php file and add the code within the construct_linkbits() function.
PhilMcKrackon
04-21-2008, 01:50 PM
You cannot use a plugin for this. You would have to edit your forum/includes/functions_vba_links_cats.php file and add the code within the construct_linkbits() function.That is what I thought, Thanks!
PhilMcKrackon
05-08-2008, 10:08 AM
Sorry for the additional questions on this but I would like to do this same thing to the "ADV_LINKS_SHOWLINK" template, where the 'Description', 'Catagory', 'URL' and such tables are. Can you point me to wich section of what PHP file creates this?
The last modification you directed me to worked great.
Thanks,
Brian
05-08-2008, 11:27 AM
You should be able to add the same code in your showlink.php file, just anywhere before the call to the ADV_LINKS_SHOWLINK template near the bottom.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.