StewardManscat
01-05-2005, 06:59 PM
We want to feature some links with graphics and stuff.
Brian has given us about eighty-six ways to do it, and I only got the product yesterday, but this solution will do for now. It's fast, easy, flexible, lemon-scented, and fits in our glove compartment.
Two steps.
1. In showlink.php find
$link['name'] = stripslashes($link['name']);
Add above:
include "./includes/functions_linkfeature.php";
2. Save this as functions_linkfeature.php and upload it to your forum/includes directory:
<?
#
# functions_linkfeature.php
# 6 jan 05 StewardManscat at vbadvanced.com
#
$linkFeature="";
$linkfilename = "$forumpath/../links/feature_$link[linkid].php";
if ( file_exists($linkfilename) )
{
ob_start();
require($linkfilename);
$linkFeature= ob_get_contents();
ob_end_clean();
}
unset($linkfilename);
?>
Notice I hard-coded my link directory in $linkfilename. All I could find kicking around was $forumpath. If somebody knows a vb variable which holds an absolute path to the web root, that would be cool. But it doesn't matter. What you want to do is construct any path to any known location where you keep a set of files as follows:
feature_1.php
feature_26.php
feature_12.php
Where each suffix is a number corresponding to the link id. If the file doesn't exist the whole thing is harmless. If it does, the output is displayed as a block on the show link details page. Get the link id number from your admin panel --Edit directory (id:XX)
Oh yeah. I lied. Three steps. Last one here:
3. In template ADV_LINKS_SHOWLINK, add a variable to display your included material. I put mine below the navbar:
$navbar
$linkFeature
<table...
Further thoughts:
Hmm. Maybe I'll put $linkFeature inside one of them standard collapsible tables. That would be a template thingy.
Numbering files by link id is horrible. But it is always unique and a valid file name. For myself, I may use the link name, and be careful never to use invalid filename characters in the link name. Or something else, I don't know. This works now.
In the first step, I just placed the include at a relatively arbitrary position in the code. If you want to use the $link[] or $customfield[] arrays in your feature_nn file, you may need to move it around. For myself I figure I have the id, so I know everything I need.
You might also not bother with separate feature files. You could construct a value for $linkFeature inside function_linkfeature.php using $link[catid] etc.
Cool thing about this method (for me): no template editing, use any php or html you want to create the feature block.
Now to stop doing what I love best (this nonsense), and get out there to sell those feature blocks to our sponsors...
Brian has given us about eighty-six ways to do it, and I only got the product yesterday, but this solution will do for now. It's fast, easy, flexible, lemon-scented, and fits in our glove compartment.
Two steps.
1. In showlink.php find
$link['name'] = stripslashes($link['name']);
Add above:
include "./includes/functions_linkfeature.php";
2. Save this as functions_linkfeature.php and upload it to your forum/includes directory:
<?
#
# functions_linkfeature.php
# 6 jan 05 StewardManscat at vbadvanced.com
#
$linkFeature="";
$linkfilename = "$forumpath/../links/feature_$link[linkid].php";
if ( file_exists($linkfilename) )
{
ob_start();
require($linkfilename);
$linkFeature= ob_get_contents();
ob_end_clean();
}
unset($linkfilename);
?>
Notice I hard-coded my link directory in $linkfilename. All I could find kicking around was $forumpath. If somebody knows a vb variable which holds an absolute path to the web root, that would be cool. But it doesn't matter. What you want to do is construct any path to any known location where you keep a set of files as follows:
feature_1.php
feature_26.php
feature_12.php
Where each suffix is a number corresponding to the link id. If the file doesn't exist the whole thing is harmless. If it does, the output is displayed as a block on the show link details page. Get the link id number from your admin panel --Edit directory (id:XX)
Oh yeah. I lied. Three steps. Last one here:
3. In template ADV_LINKS_SHOWLINK, add a variable to display your included material. I put mine below the navbar:
$navbar
$linkFeature
<table...
Further thoughts:
Hmm. Maybe I'll put $linkFeature inside one of them standard collapsible tables. That would be a template thingy.
Numbering files by link id is horrible. But it is always unique and a valid file name. For myself, I may use the link name, and be careful never to use invalid filename characters in the link name. Or something else, I don't know. This works now.
In the first step, I just placed the include at a relatively arbitrary position in the code. If you want to use the $link[] or $customfield[] arrays in your feature_nn file, you may need to move it around. For myself I figure I have the id, so I know everything I need.
You might also not bother with separate feature files. You could construct a value for $linkFeature inside function_linkfeature.php using $link[catid] etc.
Cool thing about this method (for me): no template editing, use any php or html you want to create the feature block.
Now to stop doing what I love best (this nonsense), and get out there to sell those feature blocks to our sponsors...