Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Additional Custom Banner Positions

    I had someone do this on one of my old websites about 10 years ago and I do not remember how. The guy I finally got to do it for me is now deceased.

    Questions:

    1. What files do I edit or create to position side boxes according to the array I define of banner positions?

    2. What file would I edit to define an array of banner positions?

    I have significant PHP and javascript experience but out of it for last 5 years and can figure it out if I knew what files to edit. I barely got a handle on Zencart's structure right now.

  2. #2
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: Custom Banner Positions

    Not sure I follow... Are you trying to create MORE banner sideboxes and then have new groups of banners in those sideboxes? Basically clone your "National Sponsors" sidebox?

  3. #3
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Re: Custom Banner Positions

    I am trying to create custom banner POSITIONS. I do not like the default method and want to change the banner possion IDs to something more relevant to where they are used, i.e., Header1, Header2, LeftBannerBox1,LeftBannerBox2 etc. Then I want to be able to go into the admin manual and edit those banners. In all, this will result in about 6-8 new banners and new sideboxes related to them except for header and footer ads.

    I also intend to create new side boxes, but I found a custom sidebox module for that. Problem is the module is missing the part to define the text so I edited the template itself. Being confined to working under 501(3)(c) rules, I have to have certain things on each page to stay certified under IRS and financial banking rules and regs.

    I no longer have the code and it probably had obsolete code but I had someone in here do it for me 10 years ago. He is deceased so I can't go back to him to do it and because I am setting up a charity website there is no budget for custom work.

    I am an experienced PHP programmer and can program javascript as needed. I do not need the code, just the basic outline on replacing the default banner manager and how to structure to create custom sideboxes. I do not need the coding as I can do it myself. I have read the Developer SDK online but it does not tell me enough about what I want to do.

    I did try the latest banner manager plug-in online but it crashed my site multiple times so I uninstalled and wrote it off as bad plugin until I can test it out on a test website and figure out where the foul-up is.
    Last edited by dmm2020; 10 Jan 2021 at 02:38 AM.

  4. #4
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Re: Custom Banner Positions

    I guess to be more specific what I am looking for is to create one sidebox and put a banner ad in it what files do I need to create assuming the template name is "custom"?

    Assuming that I create an array of new banner positions in a config file or definitions file, where does that go and how do I link to it?

    What files are affected in replacing the default banner manager or at least adding new banner positions to it? Or just adding the ones in the default banner manager create it without further edits? Meaning, if I enter Header1 into the Banner Manager what do I need to do to change the first header add to pickup Header1 code?

  5. #5
    Join Date
    Oct 2008
    Location
    Croatia
    Posts
    1,542
    Plugin Contributions
    19

    Default Re: Custom Banner Positions

    Still not sure I follow, but maybe this will help...

    To create new positions, you could add more banner positions in the Configuration->Layout Settings menu with this SQL:
    Code:
    INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added, use_function, set_function) VALUES
    (NULL, 'Banner Display Groups - Custom Position 1', 'CUSTOM_BANNERS_GROUP_SET1', 'custom1', 'Custom Position 1', 19, 73, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 2', 'CUSTOM_BANNERS_GROUP_SET2', 'custom2', 'Custom Position 2', 19, 74, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 3', 'CUSTOM_BANNERS_GROUP_SET3', 'custom3', 'Custom Position 3', 19, 75, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 4', 'CUSTOM_BANNERS_GROUP_SET4', 'custom4', 'Custom Position 4', 19, 76, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 5', 'CUSTOM_BANNERS_GROUP_SET5', 'custom5', 'Custom Position 5', 19, 77, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 6', 'CUSTOM_BANNERS_GROUP_SET6', 'custom6', 'Custom Position 6', 19, 79, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 7', 'CUSTOM_BANNERS_GROUP_SET7', 'custom7', 'Custom Position 7', 19, 80, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 8', 'CUSTOM_BANNERS_GROUP_SET8', 'custom8', 'Custom Position 8', 19, 81, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 9', 'CUSTOM_BANNERS_GROUP_SET9', 'custom9', 'Custom Position 9', 19, 82, NOW(), NULL, NULL),
    (NULL, 'Banner Display Groups - Custom Position 10', 'CUSTOM_BANNERS_GROUP_SET10', 'custom10', 'Custom Position 10', 19, 83, NOW(), NULL, NULL);
    This will add 10 new positions. After that, you can put the following code wherever you want:
    Code:
    if (CUSTOM_BANNERS_GROUP_SET1 != '' && $banner = zen_banner_exists('dynamic', CUSTOM_BANNERS_GROUP_SET1)) {
        if ($banner->RecordCount() > 0) {
    		echo zen_display_banner('static', $banner); 
        }
      }
    Of course, change the number for each new location.
    If you want to use it in a new sidebox, copy and rename includes/modules/sideboxes/banner_box.php to includes/modules/sideboxes/custom/custom_banner_1.php
    and includes/templates/template_default/sideboxes/tpl_banner_box.php to includes/templates/custom/sideboxes/tpl_custom_banner_1.php
    The new includes/modules/sideboxes/custom/custom_banner_1.php file should look like this:
    Code:
    <?php
    /**
     * banner_box sidebox - used to display "square" banners in sideboxes
     *
     * @copyright Copyright 2003-2020 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: DrByte 2019 Sep 09 Modified in v1.5.7 $
     */
    
    // test if box should display
    $show_banner_box = true;
    if (CUSTOM_BANNERS_GROUP_SET1 == '') {
      $show_banner_box = false;
    }
    
    if ($show_banner_box == true) {
      $banner_box = array();
      $banner_box[] = TEXT_CUSTOM_BANNER_BOX_1;
      $banner_box_group= CUSTOM_BANNERS_GROUP_SET1;
    
      require($template->get_template_dir('tpl_custom_banner_1.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_custom_banner_1.php');
    
    // if no active banner in the specified banner group then the box will not show
    // uses banners in the defined group $banner_box_group
      if ($content != '') {
        $title =  BOX_HEADING_BANNER_BOX;
        $title_link = false;
        require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default);
      }
    }
    The text in blue should be changed to something different and all can be defined in one single file, ie. includes/languages/english/extra_definitions/custom_banners.php

    Now, when you use Tools->Banner Manager, you just put your banners in custom1 group and it will show wherever you assigned custom1. Also, don't forget to enable the new sideboxes in Tools->Layout Boxes Controller.

    Hopefully that's what you were asking...

  6. #6
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Re: Custom Banner Positions

    Thanks. How do I build an array in Zencart to pull all the defined positions from MySQL so I can do a custom job on the banner_manager.php file? My plan is to switch the banner position to a dropdown box.

    Or a better question? Does this block of code call in all the banner groups? If so, I know how to create the drop down from it.

    Code:
          $new_banners_group = zen_db_prepare_input($_POST['new_banners_group']);
          $banners_group = (empty($new_banners_group)) ? zen_db_prepare_input($_POST['banners_group']) : $new_banners_group;

  7. #7
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Custom Banner Positions

    Quote Originally Posted by dmm2020 View Post
    Thanks. How do I build an array in Zencart to pull all the defined positions from MySQL so I can do a custom job on the banner_manager.php file? My plan is to switch the banner position to a dropdown box.

    Or a better question? Does this block of code call in all the banner groups? If so, I know how to create the drop down from it.

    Code:
          $new_banners_group = zen_db_prepare_input($_POST['new_banners_group']);
          $banners_group = (empty($new_banners_group)) ? zen_db_prepare_input($_POST['banners_group']) : $new_banners_group;
    Now it appears that you are looking at the bells and whistles instead of the whats and hows... Would recommend focusing on the things that are needed for the site to function and address the would be nice ifs later.

    As for a "test" site, can make one directly off of where your live site is if there is no other place available.

    As for that code? All that does is prepare the page content that was posted ($_POST) from the named element of new_banners_group and make it ready for insertion to the database. But then if that data (effectively now text) matches the php definition of being empty then instead do the same thing to the data posted through the banners_group named element.

    Understanding that the desire is to make these banner groups more humanly understood, should also realize that with the code being open source that if it had originally all been written to consider the text header1 to really only be within the first few lines of the header, then things would be "wrong" if someone moved that code to the footer area... By instead understanding where banner1 for example is displayed, it doesn't matter what the text is for the banners name as long as it is to appear in that one or more banners...

    As far as having the old code? It most certainly would help in this situation... in fact it sounds like the problem would have been solved because the code that had been written could have been compared to the code that would have been expected. Where changes were made would have identified where they likely are needed now...

    Anyways, perhaps you could provide more information about the page(s) you are wanting to have different information on and any more detail so that one could possibly suggest what changes are needed to get results sought.

    For myself, you mentioned supporting a 501(3)(c) organization. Did you mean a 501(c)(3)? And if so, where is it identified about the "additional information" that is expected on each page, etc...?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Re: Custom Banner Positions

    I know what I want. All I need to know is how to draw the banner groups into an array. I can build a drop down box from there.

    Speech about "bells and whistles" is not needed.

  9. #9
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Custom Banner Positions

    In v1.5.7, if you look at the raw HTML of the admin banner_manager page where it displays a banner-groups dropdown, you can see that its field name is banners_group.
    Then looking into the PHP for banner_manager, you can see that the dropdown for banners_group is displayed at
    https://github.com/zencart/zencart/b....php#L332-L337
    and draws its data from a query a few lines earlier at
    https://github.com/zencart/zencart/b....php#L272-L280
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #10
    Join Date
    Feb 2009
    Posts
    157
    Plugin Contributions
    0

    Default Re: Custom Banner Positions

    Thanks DrByte, that's what I need.

 

 

Similar Threads

  1. Banner positions
    By Shane78 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 16 Mar 2010, 08:49 PM
  2. Additional image positions
    By acanthuscarver in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 21 Dec 2009, 08:11 PM
  3. How to Create an additional Custom Email?
    By Decostyle in forum General Questions
    Replies: 30
    Last Post: 9 Oct 2009, 01:08 PM
  4. Additional banner sideboxes
    By ed89 in forum Basic Configuration
    Replies: 1
    Last Post: 9 Jul 2008, 11:39 AM
  5. Banner or Custom Boxes
    By bjraines in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 7 Oct 2006, 03:54 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR