Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Snowmann

Pages: [1]
1
Hallo,

ich bin gerade dabei das Script in meine Homepage zu integrieren.

Um die Hauptkategorien überall im Header anzeigen zu können, auch wenn Unterkategorien angelegt sind, habe ich in der funktions.php folgendes hinzugefügt (kopiert von get_categories):

Code: [Select]
function get_menue($cat_id = 0) {
  global $site_template, $site_db, $site_sess, $config, $lang;
  global $cat_cache, $cat_parent_cache, $new_image_cache, $subcat_ids;

  $cattable_width = ceil((intval($config['cat_table_width'])) / $config['cat_cells']);
  if ((substr($config['cat_table_width'],-1)) == "%") {
    $cattable_width .= "%";
  }

  if (!isset($cat_parent_cache[$cat_id])) {
    return "";
  }

  $visible_cat_cache = array();
  foreach ($cat_parent_cache[$cat_id] as $key => $val) {
    if (check_permission("auth_viewcat", $val)) {
      $visible_cat_cache[$key] = $val;
    }
  }

  if (empty($visible_cat_cache)) {
    return "";
  }

  $total = sizeof($visible_cat_cache);
  $table_columns = (intval($config['cat_cells'])) ? intval($config['cat_cells']) : 2;
  if ($total <= $table_columns) {
    $table_rows = 1;
  }
  else {
    $table_rows = $total / $table_columns;
    if ($total >= $table_columns && !is_integer($table_rows)) {
      $table_rows = intval($table_rows) + 1;
    }
  }

  $menue .= "<table width=\"".$config['cat_table_width']."\"border=\"0\" cellpadding=\"3\" cellspacing=\"".$config['cat_table_cellspacing']."\">\n<tr>\n<td valign=\"top\" width=\"".$cattable_width."\" class=\"schwarz\">\n";
  $count = 0;
  $count2 = 0;
  foreach ($visible_cat_cache as $key => $category_id) {
    $menue .= "";

    $is_new = (isset($new_image_cache[$category_id]) && $new_image_cache[$category_id] > 0) ? 1 : 0;
    $num_images = (isset($cat_cache[$category_id]['num_images'])) ? $cat_cache[$category_id]['num_images'] : 0;

    $site_template->register_vars(array(
      "cat_id" => $category_id,
      "cat_name" => $cat_cache[$category_id]['cat_name'],
      "cat_description" => $cat_cache[$category_id]['cat_description'],
      "cat_hits" => $cat_cache[$category_id]['cat_hits'],
      "cat_is_new" => $is_new,
      "lang_new" => $lang['new'],
      "sub_cats" => get_subcategories($category_id),
      "cat_url" => $site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$category_id),
      "random_cat_image_file" => $random_cat_image_file,
      "num_images" => $num_images
    ));
    $menue .= $site_template->parse_template("menue_bit");
    $count++;
    $count2++;
    $menue .= "";

    if ($count == $table_rows && $count2 < sizeof($visible_cat_cache)) {
      $menue .= "";
      $menue .= "";
      $menue .= "";

      $total = $total - $count2;
      $table_columns = $table_columns - 1;
      if ($total <= $table_columns && $table_columns > 1) {
        $table_rows = 1;
      }
      else {
        $table_rows = $total / $table_columns;
        if ($total >= $table_columns && !is_integer($table_rows)) {
          $table_rows = intval($table_rows) + 1;
        }
      }
      $count = 0;
    }
  }

  $menue .= "</td>\n</tr>\n</table>\n";
  return $menue;
}


Über {menue} binde ich nun dieses in den Templates ein. Sobald ich aber in eine Kategorie wechsel, werden die Unterkategorien angezeigt oder gar nichts.

Die Unterkategorien möchte ich aber mittels {categories} anzeigen lassen und zusätzlich im Kopf noch alle Hauptkategorien.

Jetzt zu meinen Fragen:  :?:
    Was kann ich im obigen Code entfernen, weil überflüssig?
    Wie muss ich obigen Code ergänzen oder umschreiben damit immer die Hauptkategorien angezeigt werden?[/list:u]
    Für Ideen  :idea: und Antworten bin ich sehr dankbar.

    Viele Grüße

    André

Pages: [1]