Hi all, I am looking to make an amendment in the breadcrumb trail in /includes/classes/kernel/Categories.php I have found the section which needs to be amended function breadcrumb($node, $lev) { $sSQL = "SELECT id,name,slug,parent_id,cLink FROM " . PREFIX . "categories WHERE id=" . Filter::mysql_quote($node); $result = $this->db->query($sSQL); $row = $result->fetch(); //slashes auto removed $path = array(); $link = ""; $name = Filter::special_chars($row['name']); if ($row['cLink'] != "") { $link = Filter::special_chars($row['cLink']); } if ($link == "") { $slug = (empty($row['slug'])) ? $row['id'] : Filter::special_chars($row['slug']); $link = "category.php?cat=" . $slug; } $path[] = "<a href='" . $link . "' title='" . $name . "' class='breadcrumb'>" . $name . " Holiday Homes</a>"; if ($row['parent_id'] != 0) { $path = array_merge($this->breadcrumb($row['parent_id'], $lev + 1), $path); } return $path; } // ------------------------------------------------------------------------ (from lines 537 to 563) I have already added the words "Holiday Homes" to the breadcrumb, but what I would like to do is add in the array I use do differentiate between holiday homes and static caravans {if in_array($categoryid, array(362,363,364,365,366,367,368,369,370,371,372,394,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,408,409,445,448,449,450,451,452,453,454,455,456,457,489))} I have tried to add the following but it does not seem to work (if indeed it will work at all) if (in_array($categoryid['362,363,364,365,366,367,368,369,370,371,372,394,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,408,409,445,448,449,450,451,452,453,454,455,456,457,489'])) { $path[] = "<a href='" . $link . "' title='" . $name . "' class='breadcrumb'>" . $name . " Caravan Hire</a>"; } else { $path[] = "<a href='" . $link . "' title='" . $name . "' class='breadcrumb'>" . $name . " Holiday Holiday</a>"; } Any thoughts on what i would need to add / amend to get it to work if it is at all possible???? Cheers Jason.
Jason, There are no "[]" in the syntax for using the in_array php function. First drop the square braces. Second, there is no such variable defined as the $categoryid, so it will never find a match and should actually generate a php error. The query results are straight from the "categories" database table. So it is just "id", but since it is an array set to the variable, "$row", you are looking to match $row['id']. It is good practice to assign an array to a variable first. Then use the assigned variable in a php function. e.g. $my_array = array(1, 2, 3, 4); in_array($row['id'], $my_array);
Mike, I really can't thank you enough... It worked like a charm The only issue I have now are the title tags, they are not showing up. Here is what I have added function breadcrumb($node, $lev) { $sSQL = "SELECT id,name,slug,parent_id,cLink FROM " . PREFIX . "categories WHERE id=" . Filter::mysql_quote($node); $result = $this->db->query($sSQL); $row = $result->fetch(); //slashes auto removed $path = array(); $link = ""; $my_array = array(362,363,364,365,366,367,368,369,370,371,372,394,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,408,409,445,448,449,450,451,452,453,454,455,456,457,489); $name = Filter::special_chars($row['name']); if ($row['cLink'] != "") { $link = Filter::special_chars($row['cLink']); } if ($link == "") { $slug = (empty($row['slug'])) ? $row['id'] : Filter::special_chars($row['slug']); $link = "category.php?cat=" . $slug; } if (in_array($row['id'], $my_array)) { $path[] = "<a href='" . $link . "' title='" . $name . "' class='breadcrumb'>" . $name . " Caravan Hire</a>"; } else { $path[] = "<a href='" . $link . "' title='" . $name . "' class='breadcrumb'>" . $name . " Holiday Homes</a>"; } Do I need to add the my_array elsewhere ? or have I done it incorrectly ? Cheers Mike for your assistance I do appreciate it