PDA

Zobacz pełną wersję : Problem z szablonem po przeniesieniu bazy danych



bartek1924
24-05-2009, 23:33
Witam, przeniosłem baze danych bez żadnych problemów, lecz teraz, gdy wejdą na stronę to wyświetlają się błędy "przed szablonem". Zamieszczam zdjęcie błędu oraz linijkę kodu do którego odwołuje się błąd:

http://i41.tinypic.com/sq0bwx.jpg



http://i41.tinypic.com/15dxnqp.jpg

zdjęcie kodu w pliku rt_splitmenu.php

Nie mam pojęcia co zmienić, żeby nie wyskakiwał błąd, proszę o pomoc...

Jola
25-05-2009, 00:08
Był taki wierszyk o dzieleniu przez zero. PHP nie rymuje, ale wyraźnie krzyczy, że count($tab_colors) jest równe zero i nie umie przez nie podzielić ( ja też).
Tyle tylko mogę powiedzieć na podstawie tej informacji.:)

bartek1924
25-05-2009, 15:52
Dzięki za odp., nie wiem czy błąd nie leży po stronie hostingodawcy i jego serwera (darmowy 000webhost.com) dzieje się tak tylko z jednym szablonem, na az.pl nie było żadnego błędu, chyba będę musiał poszukać innego serwera, albo próbować dalej, jeżeli ktoś miałby jakiś pomysł to proszę o odpowiedź, pozdrawiam!

Jola
25-05-2009, 16:09
Na az.pl po prostu nie pokazywał błędu!
Wina jest po stronie skryptu templatki. Podaj link do niej. Albo więcej kodu.
Pozdrawiam

bartek1924
25-05-2009, 23:23
Zamieszczam kod pliku rt_splitmenu.php



<?php

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

if (!defined( '_MOS_SUBMENU_MODULE' )) {
/** ensure that functions are declared only once */
define( '_MOS_SUBMENU_MODULE', 1 );
$hilightid = -1;
$menuname = null;

$tab_colors = array();
$tab_color = 'white';
$tab_index = 0;

/**
* Utility function for writing a menu link
*/
function rtGetTabColor() {
global $tab_color;
return $tab_color;
}


function rtGetHilightid() {
global $hilightid;
return $hilightid;
}

function rtGetSubMenuLink( $mitem, $level, $hilight=false , $color_index=false) {
global $Itemid, $mosConfig_live_site, $mainframe, $hilightid, $menuname, $tab_colors, $tab_color, $tab_index, $forcehilite;
$txt = '';
$id = '';

switch ($mitem->type) {
case 'separator':
case 'component_item_link':
break;
case 'content_item_link':
$temp = split("&task=view&id=", $mitem->link);
$mitem->link .= '&Itemid='. $mainframe->getItemid($temp[1]);
break;
case 'url':
if ( eregi( 'index.php\?', $mitem->link ) ) {
if ( !eregi( 'Itemid=', $mitem->link ) ) {
$mitem->link .= '&Itemid='. $mitem->id;
}
}
break;
case 'content_typed':
default:
$mitem->link .= '&Itemid='. $mitem->id;
break;
}

if ($color_index) {
$id .= $tab_colors[($tab_index)%count($tab_colors)];
$tab_index++;

}
// Active Menu highlighting
$current_itemid = trim( mosGetParam( $_REQUEST, 'Itemid', 0 ) );
if ( !$current_itemid && !$hilight ) {
//$id = '';
} else if (($forcehilite && $hilight) || (($current_itemid == $mitem->id || $hilight) && !$forcehilite)) {
if ($level == 0) {
$tab_color = $id;
$menuname = $mitem->name;
$hilightid = $mitem->id;
}
$id .= 'active_menu';
}

$id = ' class="' . $id . '"';
$mitem->link = ampReplace( $mitem->link );

if ( strcasecmp( substr( $mitem->link,0,4 ), 'http' ) ) {
$mitem->link = sefRelToAbs( $mitem->link );
}

switch ($mitem->browserNav) {
// cases are slightly different
case 1:
// open in a new window
$txt = '<li'. $id . '><a href="'. $mitem->link .'" target="_blank">'. $mitem->name ."</a></li>\n";
break;

case 2:
// open in a popup window
$txt = "<li". $id . "><a href=\"#\" onclick=\"javascript: window.open('". $mitem->link ."', '', 'toolbar=no,location=no,status=no,menubar=no,scrol lbars=yes,resizable=yes,width=780,height=550'); return false\">". $mitem->name ."</a></li>\n";
break;

case 3:
// don't link it
$txt = '<li'. $id . '><span class="seperator">'. $mitem->name ."</span></li>\n";
break;

default: // formerly case 2
// open in parent window
$txt = '<li'. $id . '><a href="'. $mitem->link .'">'. $mitem->name ."</a></li>\n";
break;
}

return $txt;
}



function rtShowHorizMenu( $menutype) {
global $database, $my, $cur_template, $Itemid, $hilightid, $forcehilite;
global $mosConfig_absolute_path, $mosConfig_shownoauth;

$topnav = '';

if ($mosConfig_shownoauth) {
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND published='1' AND parent=0"
. "\nORDER BY ordering";
} else {
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND published='1' AND access <= '$my->gid' AND parent=0"
. "\nORDER BY ordering";
}
$database->setQuery( $sql );

$topmenu = $database->loadObjectList( 'id' );

//work out if this should be highlighted
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND published='1'";
$database->setQuery( $sql );
$subrows = $database->loadObjectList( 'id' );
$maxrecurse = 5;
$parentid = $Itemid;

//this makes sure toplevel stays hilighted when submenu active
while ($maxrecurse-- > 0) {
$parentid = getParentRow($subrows, $parentid);
if (isset($parentid) && $parentid >= 0 && $subrows[$parentid]) {
$hilightid = $parentid;
} else {
break;
}
}

$links = array();
$i = 0;
foreach ($topmenu as $menuitem) {
$hilight = false;
if (isset($forcehilite) && $forcehilite && $forcehilite == $i++) {
$hilight = true;
} else {
if ($menuitem->id == $hilightid) {
$hilight = true;
}
}
$links[] = rtGetSubMenuLink( $menuitem, 0, $hilight, true );
}




$menuclass = 'toplevel';
if (count( $links )) {

$topnav .= '<ul id="'. $menuclass .'">';
foreach ($links as $link) {
$topnav .= $link;
}
$topnav .= '</ul>';

}
return $topnav;
}

function getParentRow($rows, $id) {
if (isset($rows[$id]) && $rows[$id]) {
if($rows[$id]->parent > 0) {
return $rows[$id]->parent;
}
}
return -1;
}

/**
* Vertically Indented Menu
*/
function rtShowSubMenu( $menutype, $pre=NULL, $post=NULL ) {
global $database, $my, $cur_template, $Itemid;
global $mosConfig_absolute_path, $mosConfig_live_site, $mosConfig_shownoauth;

$sidenav = '';

/* If a user has signed in, get their user type */
$intUserType = 0;
if($my->gid){
switch ($my->usertype) {
case 'Super Administrator':
$intUserType = 0;
break;
case 'Administrator':
$intUserType = 1;
break;
case 'Editor':
$intUserType = 2;
break;
case 'Registered':
$intUserType = 3;
break;
case 'Author':
$intUserType = 4;
break;
case 'Publisher':
$intUserType = 5;
break;
case 'Manager':
$intUserType = 6;
break;
}
} else {
/* user isn't logged in so make their usertype 0 */
$intUserType = 0;
}

if ($mosConfig_shownoauth) {
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND published='1'"
. "\nAND parent > 0"
. "\nORDER BY parent,ordering";
} else {
$sql = "SELECT m.* FROM #__menu AS m"
. "\nWHERE menutype='". $menutype ."' AND published='1' AND access <= '$my->gid'"
. "\nAND parent > 0"
. "\nORDER BY parent,ordering";
}
$database->setQuery( $sql );
$rows = $database->loadObjectList( 'id' );


// establish the hierarchy of the menu
$children = array();
// first pass - collect children


foreach ($rows as $v ) {
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}



// second pass - collect 'open' menus
$open = array( $Itemid );
$count = 20; // maximum levels - to prevent runaway loop
$id = $Itemid;
while (--$count) {
if (isset($rows[$id]) && $rows[$id]->parent > 0) {
$id = $rows[$id]->parent;
$open[] = $id;
} else {
break;
}
}

if (isset($children[$id]) && $children[$id]) {
$sidenav = rtRecurseSubMenu( $id, 1, $children, $open);
}
return $sidenav;

}

/**
* Utility function to recursively work through a vertically indented
* hierarchial menu
*/
function rtRecurseSubMenu( $id, $level, &$children, &$open) {
global $Itemid, $menuname;

$output = "";
$sub_class = "submenu";

if (@$children[$id]) {
//$n = min( $level, count( $indents )-1 );
if ($level == 1 ) {
$output .= "<div class=\"moduletable\"><h3>" . $menuname . " Menu</h3>\n";
$output .= "<ul class=\"" . $sub_class . "\">\n";
} else {
$output .= "<ul>\n";
}


foreach ($children[$id] as $row) {
$output .= rtGetSubMenuLink( $row, $level );
if ( in_array( $row->id, $open )) {
$output .= rtRecurseSubMenu( $row->id, $level+1, $children, $open );
}
}


$output .= "</ul>\n";

if ($level == 1) {
$output .= "</div>\n";
}
}
return $output;
}

function beginsWith( $str, $sub ) {
return ( substr( $str, 0, strlen( $sub )-1 ) == $sub );
}

}

?>

bartek1924
25-05-2009, 23:34
Dodam jeszcze, że gdy wklepałem w walidator adres strony to pokazywało 100% poprawność kodu (az.pl)

adres do theme'a:
http://www.rockettheme.com/joomla-templates/extremities2


dodaje jeszcze zrzuz z ustawień instalacji, może rzeczywiście błąd jest po stronie templatki bo na az.pl wyświetlanie błędów miałem wyłączone, o ile o to chodzi.
http://i39.tinypic.com/otjbzn.jpg

gdzie w cPanelu można wyłączyć wyświetlanie błędów? O ile jest taka możliwość na 000webhost...

Jola
26-05-2009, 01:57
Wiadomość 1 - fajny adres, ale raczej nie będę płacić za podejrzenie kodu.
Wiadomość 2 - ten skrypt nie do końca pokazuje źródło błędu
Wiadomość 3 - podejrzewam, że taka modyfikacja rozwiąże Twój problem:
zamiast

if ($color_index) {
$id .= $tab_colors[($tab_index)%count($tab_colors)];
$tab_index++;
}wstaw

if ($color_index) {
$ile = count($tab_colors);
if ($ile == 0) $ile = 1;
$id .= $tab_colors[($tab_index)%$ile];
$tab_index++;
}Błąd powinien zniknąć

bartek1924
26-05-2009, 17:34
Jolu jesteś wielka, błąd zniknął!!! Dziękuję Ci za wszystko i pozdrawiam serdecznie! :)


Błąd zniknął, ale zniknęło też górne menu:) chyba dam sobie spokój i napisze do admina hostingu czy mógłby wyłączyć pokazywanie błędów...

Jola
26-05-2009, 18:55
Bez całego kodu to wróżenie z fusów. spróbuj jeszcze tak: (jeśli wcześniej wszystko się wyświetlało tylko wysypywały się błędy)

$ile = count($tab_colors);
if ($color_index && $ile != 0) {
$id .= $tab_colors[($tab_index)%$ile];
$tab_index++;
} lub tak:

if ($color_index) {
$ile = count($tab_colors);
if (!$ile)
$id .= $tab_colors[($tab_index)%$ile];
$tab_index++;
}To drugie bardziej prawdopodobne.
Przerzucę się na wróżbiarstwo! :)

bartek1924
26-05-2009, 22:39
Już straciłem nadzieje, ale zadziałał pierwszy sposób i wszystko super chodzi:) nie wiem jak się odwdzięczę za wszystko, dziękuję bardzo jeszcze raz!