Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2005
    Posts
    99
    Plugin Contributions
    0

    Default CSS Flyout Header?

    I use the CSS Flyout Header for a website that I'm designing. I have the top categories going across the top navigation bar, my question is I want to be able to identify the last category in the list. I'm assuming that I have to modify the categories_ul_generator.php file. Just can't get my head around and where to put the proper code to identify the last category in the list.

    http://uromed.ca/catalog/nav.php

    Code:
    <?php
    //
    // +----------------------------------------------------------------------+
    // |zen-cart Open Source E-commerce                                       |
    // +----------------------------------------------------------------------+
    // | Copyright (c) 2003 The zen-cart developers                           |
    // |                                                                      |
    // | http://www.zen-cart.com/index.php                                    |
    // |                                                                      |
    // | Portions Copyright (c) 2003 osCommerce                               |
    // +----------------------------------------------------------------------+
    // | This source file is subject to version 2.0 of the GPL license,       |
    // | that is bundled with this package in the file LICENSE, and is        |
    // | available through the world-wide-web at the following url:           |
    // | http://www.zen-cart.com/license/2_0.txt.                             |
    // | If you did not receive a copy of the zen-cart license and are unable |
    // | to obtain it through the world-wide-web, please send a note to       |
    // | [email protected] so we can mail you a copy immediately.          |
    // +----------------------------------------------------------------------+
    // $Id: categories_ul_generator.php 2004-07-11  DrByteZen $
    //      based on site_map.php v1.0.1 by networkdad 2004-06-04
    //
    
    
    class zen_categories_ul_generator {
        var $root_category_id = 0,
        $max_level = 6,
        $data = array(),
        $root_start_string = '',
        $root_end_string = '',
        $parent_start_string = '',
        $parent_end_string = '',
    
        $parent_group_start_string = '<ul%s>',
        $parent_group_end_string = '</ul>',
    
        $child_start_string = '<li%s>',
        $child_end_string = '</li>',
    
        $spacer_string = '
    	',
        $spacer_multiplier = 1;
    
        var $document_types_list = ' (3) ';// acceptable format example: ' (3, 4, 9, 22, 18) '
    
        function zen_categories_ul_generator($load_from_database = true)
        {
            global $languages_id, $db;
            $this->data = array();
            $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
                                 from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
                                 where c.categories_id = cd.categories_id
                                 and c.categories_status=1 " .
                                 " and cd.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
                                 " order by c.parent_id, c.sort_order, cd.categories_name";
            $categories = $db->Execute($categories_query);
            while (!$categories->EOF) {
              $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
                $categories->MoveNext();
            }
        }
    
        function buildBranch($parent_id, $level = 1, $submenu=false) {
          if ($parent_id != '0') {
            $result = sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level) . '"' : '' );
          }
            if (($this->data[$parent_id])) {
                foreach($this->data[$parent_id] as $category_id => $category) {
                  $category_link = $category_id;
    			  if (($this->data[$category_id])) {
                    $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
    			  } else {
                    if (($this->data[$category_id]) && ($submenu==false)) {
                      $result .= sprintf($this->parent_group_start_string, ($submenu==true) ? ' class="level'. ($level+1) . '"' : '');
                      $result .= sprintf($this->child_start_string, ($submenu==true) ? ' class="submenu"' : '');
                    } else {
                      $result .= sprintf($this->child_start_string, '');
                    }
    			  }
                  if ($level == 0) {
                    $result .= $this->root_start_string;
                  }
                  $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
                  $result .= $category['name'];
                  $result .= '</a>';
                  if ($level == 0) {
                    $result .= $this->root_end_string;
                  }
                  if (($this->data[$category_id])) {
                    $result .= $this->parent_end_string;
                  }
                  if (($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
                    $result .= $this->buildBranch($category_id, $level+1, $submenu);
                  }
                  $result .= $this->child_end_string . "\n";
                }
            }
            if ($level > 0) {
              $result .= $this->parent_group_end_string;
            }
            return $result;
        }
    
        function buildTree($submenu=false)
        {
            return $this->buildBranch($this->root_category_id, '', $submenu);
        }
    }
    ?>
    Last edited by kdlklm; 22 Oct 2014 at 10:26 PM.

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,061
    Plugin Contributions
    25

    Default Re: CSS Flyout Header?

    Code:
    #dropMenu>.level_1>li:last-child {your: style;}
    This works in essentially all browsers except IE8 and older.

  3. #3
    Join Date
    Jul 2012
    Posts
    15,131
    Plugin Contributions
    17

    Default Re: CSS Flyout Header?

    While that would seem to be a ways to apply css style modification, perhaps the question is, what is the intended action to be taken when the last category is known? Is there something programmatic to be performed? (Could look at the RecordCount() for the variable returned by the sql statement) or is it something like proposed by gjh42 where a CSS action is being taken on the final category of the list. Btw, I'm a little turned around on what level that statement will act as I also don't understand with the flyout function whether menu options go right or down. And regardless of the direction is the request to act/collect info on a menu options list, or the entire menu itself to identify the last item in the menu that could give a possible flyout set of choices... I'm thinking gjh42 has a good grasp on the situation, but that the issue is not well documented for those not in the know. :) (or, if like I feel at the moment, those in the dark. )
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...
    Upgraded to Zen Cart V1.5.3 from V1.5.1 from V1.5.0 from V1.3.9h

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,061
    Plugin Contributions
    25

    Default Re: CSS Flyout Header?

    True, the OP has not described the reason for identifying the last category in the list. I assumed it was for styling purposes, which would be probably the most common application.

    The rule I posted would apply only to a top level category tab in this menu. By the pseudo-selector description, it would actually apply to the last child of the category's parent, which in this case will be a category item.
    Last edited by gjh42; 23 Oct 2014 at 07:41 AM.

  5. #5
    Join Date
    Apr 2005
    Posts
    99
    Plugin Contributions
    0

    Default Re: CSS Flyout Header?

    Yes you are right, it is for styling purposes. But it would be nice to be able to specify it in the PHP code, rather than CSS3.

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,061
    Plugin Contributions
    25

    Default Re: CSS Flyout Header?

    Do you have any measurable traffic from customers using IE8 or older? If not, using CSS to identify elements for styling will avoid the need to maintain PHP file changes through every ZC version upgrade you do.

  7. #7
    Join Date
    Apr 2005
    Posts
    99
    Plugin Contributions
    0

    Default Re: CSS Flyout Header?

    Yes you're right, I'm definitely going go with the CSS option. Thank you very much for your help.

 

 

Similar Threads

  1. layout changed after installed CSS Horizontal Drop Down Menu (CSS Flyout Header 1.5)
    By cmike in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 20 Feb 2014, 04:02 PM
  2. v151 How to uninstall CSS Horizontal Drop Down Menu (CSS Flyout Header 1.5)
    By cmike in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 15 Feb 2014, 07:39 AM
  3. v139h CSS Flyout header
    By bravo14 in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 30 Mar 2012, 01:35 PM
  4. Css Flyout Header!
    By mike-b in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 5 Mar 2010, 09:23 PM

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