Forums / All Other Contributions/Addons / banner_box_all for all banner groups

banner_box_all for all banner groups

Locked

Views: 734

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
28 Sep 2010, 5:14 AM
#1
frobie avatar

frobie

New Zenner

Join Date:
Sep 2010
Posts:
1
Plugin Contributions:
0

banner_box_all for all banner groups

I am not sure where to post this; but, this is my solution for applying the same properties of the banner_box_all to all banner groups.

I took the code from sideboxes/tpl_banner_box_all.php and added it as a function in includes/functions/banner.php.

Here is the function in its entirety:

////
// Displays all banners from specified group
  function zen_display_all_banners($action, $identifier, $display=true) {
    global $db, $request_type;

    switch ($request_type) {
      case ('SSL'):
        $my_banner_filter=" and banners_on_ssl= " . "1 ";
        break;
      case ('NONSSL'):
        $my_banner_filter='';
        break;
    }
    $new_banner_search = zen_build_banners_group($identifier);
    
    $sql = "select banners_id, banners_title, banners_image, banners_html_text, banners_open_new_windows, banners_url from " . TABLE_BANNERS . " where status = 1 " . $new_banner_search . $my_banner_filter;
    if ($action == "dynamic") {
      $sql .= " order by rand()";
    } else {
      $sql .= " order by banners_sort_order";
    }
    $banners_all = $db->Execute($sql);
    
    $banner_cnt = 0;
    $content = "";
    while (!$banners_all->EOF) {
      $code = zen_display_banner('static', $banners_all->fields['banners_id']);
      $data[$banner_cnt] = $banners_all->fields;
      $data[$banner_cnt]["banners_image_link"] = DIR_WS_IMAGES . $banners_all->fields['banners_image'];
      $data[$banner_cnt]["banners_html_link"] = zen_href_link(FILENAME_REDIRECT, 'action=banner&goto=' . $banners_all->fields['banners_id']);
      $data[$banner_cnt]["banners_code"] = $code;
      $content .= $code;
      if ($banner_cnt < $banners_all->RecordCount()) {
        $content .= '<br /><br />';
      }
      $banner_cnt++;
      $banners_all->MoveNext();
    }
    
    if ($banner_cnt == 0) {
      return false;
    }
    
    if ($display) {
      return $content;
    }
    return $data;
  }

Definition for the function parameters:

$action: "dynamic" = random; "static" = by sort order
$identifier: the banner group id
$display: true = returns the same content as sideboxes/tpl_banner_box_all.php; false = returns an array of banners

Fields in the array of banners:

banners_id: banner id
banners_title: banner title
banners_image: banner image file name
banners_html_text: the alt text for banner ?
banners_open_new_windows: whether the banner should open in a new window
banners_url: the url the banner should click to
banners_code: the code you get from zen_display_banner()
banners_image_link: the image path found in banners_code
banners_html_link: the link path found in banners_code

For example, to access the banner title for the 2nd banner in the "Banner Display Groups - Header Position 2" group, you would do:

$banners = zen_display_all_banners("static",SHOW_BANNERS_GROUP_SET2, false);
$title = $banners[1]["banners_title"];

To get the same results as tpl_banner_box_all.php, you would do:

$banners = zen_display_all_banners("dynamic",SHOW_BANNERS_GROUP_SET2);
echo $banners;

Hope this helps someone.

29 Sep 2010, 11:56 PM
#2
shaner avatar

shaner

New Zenner

Join Date:
Sep 2010
Posts:
2
Plugin Contributions:
0

Re: banner_box_all for all banner groups

Sorry, this has nothing to do with your post. But please can you help?

Hi there. I am looking for some help! I going nuts trying to figure this out! :frusty:
I am trying to put small icons which are in .gif in my bannerboxes. When I check if they are there, all I see is a square inside the bannerbox with another square in the top right corner with a red X in it.
Why is this happening and how can I resolve this?

Im using the classic template. Ive installed my own header though and changed the color of the template.

Please help!:cry: