Results 1 to 4 of 4

Thread: dynamic category menu on every site

  1. #1
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default dynamic category menu on every site

    Hello,

    I still trying to get my old dynamic category menu to work.

    A working demo you can see here:
    http://www.webgemaelde.de/kunst/category/2

    The problem is, that know I don't like this form of mod_rewrite, because I have a lot of problems with my relativ paths because of the new sub-directory.

    I tried a lot, but I can't change this mod to get it work with normal indexu, perhaps a php-profi will see the error faster

    At the bottom you find the php-code of dmenu. It will form with an own template, that will call the va <%category%>
    .

    Hope you can help

    Greetings
    Frank

    <?php

    function ShowDMenu() {
    $catimg = 'N';
    $cat_table_width = "50"; // table width
    $cat_cellspacing = "0"; // table cellspacing
    $cat_font_face = "Arial"; // category font face
    $cat_font_size = "2"; // category font color
    $cat_link_style = "font-size: 11px; color: #0033cc;"; // category link style
    $subcat_font_face = "Arial"; // sub category font face
    $subcat_font_size = "1"; // sub category font color
    $subcat_link_style = "font-size: 10px; color: #0033cc;"; // sub category link style
    $cat_columns = 1;
    $max_sub_cat = 20;
    $SPACER = '&nbsp;&middot;&nbsp;';
    $cat_default_image = "images/folder.gif";
    $indexudir = "http://localhost/indexu/";


    // vars global configuration
    global $conn, $dbServer, $dbHostname, $dbUsername, $dbPassword, $dbName,
    $theme_path, $cache_time,$use_cache_status,$theme_name,
    $cat_description_format, $COOKIE_USERNAME;

    // vars template
    global $category;

    // show categories
    $category_obj = new clsCategory;
    $category_obj->InitDB($dbServer,$dbHostname,$dbUsername,$dbPassw ord,$dbName);

    $category_obj->table_name = "idx_category";
    $category_obj->link_table_name = "idx_link";
    $category_obj->number_of_columns = $cat_columns;
    $category_obj->number_of_subcats = $max_sub_cat;

    $category_obj->default_image = $cat_default_image;
    $category_obj->image_path = "themes/".$theme_name."/images/";

    $category_obj->show_subcat = true;
    $category_obj->parent = 0;

    $category = $category_obj->DisplayDM($indexudir, $SPACER, $catimg, $max_sub_cat, $cat_table_width, $cat_cellspacing, $cat_font_face, $cat_font_size, $cat_link_style, $subcat_font_face, $subcat_font_size);

    DisplayTemplate($theme_path."dmenu.html","\$catego ry");

    }


    // ---------------
    // main program
    // ---------------

    $conn = ConnectDB();
    $title = $titles["1101"];

    $theme_name = GetTheme($COOKIE_USERNAME);
    if(empty($theme_name)) $theme_name = "default";

    $theme_path = $theme_path.$theme_name."/";

    ShowDMenu();

    ?>

  2. #2
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    based on what I see, you have a function called DisplayDM in the category.class.php file.

    you would be better off passing the variables to DisplayDM in the form of $category_obj->cat_table_width = "50"; rather than as an argument to the function itself. but either will work.

    but here is the question: it doesn't look like the menu changes. so do you need a "dynamic" menu?

    Without seeing DisplayDM, I would say you do not need a dynamic menu because once the category information is created, it rarely changes.

    I would suggest that you just create the menu using normal HTML and include it wherever you want to show the menu.

    that way you just have the browser requesting an additional bit of HTML rather than doing a myslq search, formating the result and then sending it to browser.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

  3. #3
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    1,180

    Default yep !

    Sorry, you are right, i post the code at the bottom.

    Why I won't a dynamic menu ?

    I think it is much easier to use, because if I change, delete or add some cats I allways must change the template, too.
    With a dynamic menu I needn't to change anythings - sounds easier

    I think the problem is the path, in webgemaelde.de/kunst/ I use a mod_rewrite, that forms browse?=1 to category/1.
    Fine, but the problem is the new sub-folder.

    Greetings
    Frank

    //ADDED FOR DMENU
    function DisplayDM($indexudir, $SPACER, $catimg, $max_sub_cat, $cat_table_width, $cat_cellspacing, $cat_font_face, $cat_font_size, $cat_link_style, $subcat_font_face, $subcat_font_size) {
    // get main category

    if(empty($this->query))
    $query = "select * from $this->table_name where (parent_id = $this->parent and visible = 1) order by name";
    else $query = $this->query;

    $result = $this->db_connect->Execute($query);
    $num_cats = $result->RecordCount();

    if($num_cats!=0) {
    $dmenu = $this->header;
    // $dmenu .= "<table width=$cat_table_width cellspacing=$cat_cellspacing>\n";
    // $dmenu .= "<tr>";


    $st = $num_cats%$this->number_of_columns;
    if($st==0) {
    $col1 = floor($num_cats/$this->number_of_columns);
    $col2 = floor($num_cats/$this->number_of_columns);
    $col3 = floor($num_cats/$this->number_of_columns);
    }
    if($st==1) {
    $col1 = floor($num_cats/$this->number_of_columns) + 1;
    $col2 = floor($num_cats/$this->number_of_columns);
    $col3 = floor($num_cats/$this->number_of_columns);
    }
    if($st==2) {
    $col1 = floor($num_cats/$this->number_of_columns) + 1;
    $col2 = floor($num_cats/$this->number_of_columns) + 1;
    $col3 = floor($num_cats/$this->number_of_columns);
    }
    if($st==3) {
    $col1 = floor($num_cats/$this->number_of_columns) + 1;
    $col2 = floor($num_cats/$this->number_of_columns) + 1;
    $col3 = floor($num_cats/$this->number_of_columns) + 1;
    }

    $k=0;
    while($k<$this->number_of_columns) {
    $width = 100 / $this->number_of_columns;
    // $dmenu .= "<td width=$width"."% valign=top>\n";

    if($k==0) { $i=0; $max_loop = $col1; }

    if($k==1) {
    $i = $max_loop;
    $max_loop = $max_loop+$col2;
    }

    if($k==2) {
    $i = $max_loop;
    $max_loop = $max_loop+$col3;
    }

    if($k==3) {
    $i=$max_loop;
    $max_loop = $num_cats;
    }

    while($i < $max_loop){

    $result->Move($i);
    $cat_id = $result->Fields("category_id");
    $cat_name = $result->Fields("name");
    $cat_description = $result->Fields("description");
    $cat_image = $result->Fields("image");
    $nl = $result->Fields("links");
    $result->MoveNext();

    if($catimg != "Y") $image = "";
    else {
    if($cat_image=="") $cat_image = $this->default_image;
    else $cat_image = $this->image_path.$cat_image;
    $image = "<img src='$cat_image'>";
    }

    $cat_desc = str_replace("<%cat_description%>",$cat_description ,$this->cat_description_format);

    $cat_url = $this->category_filename.'/'.$cat_id;
    $cat_url = $indexudir.$cat_url;

    if($this->type_of_list=="STANDART_LIST") {
    $dmenu .= "$image <FONT FACE=$cat_font_face SIZE=$cat_font_size>";
    $dmenu .= "<B><A HREF=\"$cat_url\" style=\"$this->cat_link_style\">$cat_name</A></B> $html_number_of_links \n";
    $dmenu .= "$number_of_links\n";
    if($this->show_subcat) $dmenu .= "<br>";
    }


    // get sub category

    if($this->show_subcat) {

    $query = "select category_id, name from $this->table_name where parent_id=\"$cat_id\" order by name";
    $result_sub = $this->db_connect->Execute($query);
    $num_subs = $result_sub->RecordCount();

    $j = 0;

    while(($j < $num_subs) && ($j < $this->number_of_subcats)){
    $result_sub->Move($j);
    $sub_id = $result_sub->Fields("category_id");
    $sub_name = $result_sub->Fields("name");
    $result_sub->MoveNext();

    $sub_url = $this->category_filename.'/'.$sub_id;
    $sub_url = $indexudir.$sub_url;
    $dmenu .= "<FONT FACE=$subcat_font_face SIZE=$subcat_font_size>\n";
    $dmenu .= $SPACER."<A HREF=\"$sub_url\" style=\"$this->subcat_link_style\">$sub_name</A><BR>";

    $j++;


    }
    }

    $i++;
    }
    $k++;
    // $dmenu .= "</td>\n\n";
    }
    // $dmenu .= "</tr></table>";
    }

    return $dmenu;
    }

    }

    ?>

  4. #4
    Join Date
    Apr 2003
    Location
    Atlanta GA
    Posts
    3,395

    Default

    well, I did have one links site where I added some Canadian locations after a year or so.

    But for me, in a three year period, I only made two changes to the categories.

    You may be different. You may be adding categories each month.

    To me it is easier to write HTML than to write PHP.
    esm
    "The older I get, the more I admire competence, just simple competence, in any field from adultery to zoology."

    .

Similar Threads

  1. Replies: 0
    Last Post: 02-13-2004, 08:56 PM
  2. Full site links in a popup menu?
    By dulger in forum v5.x
    Replies: 2
    Last Post: 11-07-2003, 09:55 AM
  3. New Mod - Dynamic Menu MOD
    By esm in forum v3.2
    Replies: 0
    Last Post: 11-02-2003, 06:55 AM
  4. Category Jump Hack/Mod ??
    By ideavirus in forum v3.2
    Replies: 9
    Last Post: 06-27-2003, 10:11 AM
  5. Replies: 4
    Last Post: 03-18-2003, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •