i have some kind of logic going on in the brands template page.
i don’t know at what part i should add a filter and how everything fits together. i’ve never done something with filters.
basically i have to add this function to the plugin and somewhere add filter? what do i do in the template page?
in my plugin i have functions like:
one_brand($ID)
all_brands($letter, $in, $limit, $breakafter, $orderby)
Excerpt, brands.php template page:
<?php
// adaption for WP2: just isset doesn't work anymore, that's why we assign $_GET to $l, etc.
$l = $_GET['l'];
$b = $_GET['b'];
$in = $_GET['in'];
// adaption end
if (! isset($b)) {
if (! isset($l) && ! isset($in)) {
$letter = "";
echo '<h2 class="capheadsmall" style="padding-top: 10px">RECENTLY ADDED BRANDS</h2>';
all_brands($letter, $in, 21, 3, 'date');
} elseif (isset($l)) {
$letter = $l;
echo '<h2 class="capheadsmall" style="padding-top: 10px">BRANDS: ' . $letter . '</h2>';
all_brands($letter, $in, null, 3, 'brand_name');
} elseif (isset($in)) {
echo '<h2 class="capheadsmall" style="padding-top: 10px; text-transform: uppercase;">' . str_replace("-", " ", $in) . ' Brands</h2>';
all_brands($letter, str_replace("-", " ", $in), null, 3, 'brand_name');
}
} else {
if (! isset($b)) {
$ID = "";
} else {
$ID = $b;
}
one_brand($b);
all_ads($ID, $in, $letter);
brand_news($b);
}
Excerpt plugin:
function one_brand ($ID) {
$letter = $_GET['l'];
global $wpdb;
$sql = "SELECT ID, brand_name, brand_desc, brand_industry, brand_link, brand_img FROM wp_brands WHERE ID = $ID AND brand_active = 1";
$results = $wpdb->get_results($sql);
$output = '';
foreach ($results as $result) {
$brand_name = stripslashes($result->brand_name);
$brand_link = $result->brand_link;
$brand_img = $result->brand_img;
$brand_desc = stripslashes($result->brand_desc);
$brand_industry = $result->brand_industry;
$output .= '<div style="line-height: 17px; padding-top: 10px">' . $before;
if ($brand_img != "") {
$output .= '<div style="float: right; padding-left: 20px; padding-bottom: 0px; padding-top: 10px"><img src="/wp-content/random-brand/' . $brand_img . '" style="margin: 3px 0 5px 0" alt="Link: ' . $brand_name . '" /></div>';
}
$output .= '<h2 style="padding-bottom: 0px; margin-bottom: 3px; color: #2e2e2e">'. $brand_name . '</h2>Industry: ' . $brand_industry . '
' . $brand_link . '
' . $brand_desc . $after . '</div>';
}
echo $output;
// Display Brandlinks
$sql = "SELECT * FROM wp_brands_links WHERE brandID = $ID";
$results = $wpdb->get_results($sql);
if ($results != "") {
$output = '<div class="brands_links"><h4 style="margin-top: 0; padding-top: 3px">Pages found on ' . substr($brand_link, 7) . ' <span style="font-weight: normal">(beta)</span></h4>';
$trenn = "";
foreach ($results as $result) {
$type = $result->type;
$link = $result->link;
if ($type == 4) { $output .= $trenn . 'About'; $trenn = " | "; }
if ($type == 1) { $output .= $trenn . 'News'; $trenn = " | "; }
if ($type == 6) { $output .= $trenn . 'Products'; $trenn = " | "; }
if ($type == 7) { $output .= $trenn . 'Shop'; $trenn = " | "; }
if ($type == 5) { $output .= $trenn . 'Jobs'; $trenn = " | "; }
if ($type == 2) { $output .= $trenn . 'Press'; $trenn = " | "; }
if ($type == 3) { $output .= $trenn . 'Contact'; $trenn = " | "; }
}
echo $output . "</div>";
}
// Display Slogans
$sql = "SELECT * FROM wp_brands_slogans WHERE brandID = $ID ORDER BY year DESC";
$results = $wpdb->get_results($sql);
if ($results != "") {
$output = '<h2 class="capheadsmall" style="margin-top: 30px; margin-bottom: 5px; text-transform: uppercase">' . $brand_name . ' Slogans</h2><table cellpadding="0" cellspacing="0" width="100%">';
foreach ($results as $result) {
$slogan_desc = stripslashes($result->desc);
$slogan_year = $result->year;
if($slogan_year == "0000") { $slogan_year = ""; }
$output .= '<tr><td width="90%" style="border-bottom: 1px solid #F3E9E2">' . $slogan_desc . '</td><td width="10%" style="padding: 3px 0px 3px 0px; border-bottom: 1px solid #F3E9E2">' . $slogan_year . '</td></tr>';
}
echo $output;
echo "</table>";
}
}