PDA

View Full Version : [PHP] Come inserire CSS


Traxsung
23-08-2008, 07:11
Ragazzi ho un problemino che non riesco a risolvere

Ho questo codice in php:


function tep_show_category($counter) {
global $tree, $categories_string, $cPath_array;

for ($i=0; $i<$tree[$counter]['level']; $i++) {
$categories_string .= "&nbsp;&nbsp;";
}

$categories_string .= '<a href="';

if ($tree[$counter]['parent'] == 0) {
$cPath_new = 'cPath=' . $counter;
} else {
$cPath_new = 'cPath=' . $tree[$counter]['path'];
}

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new) . '">';

if (isset($cPath_array) && in_array($counter, $cPath_array)) {
$categories_string .= '<b>';
}

// display category name
$categories_string .= $tree[$counter]['name'];

if (isset($cPath_array) && in_array($counter, $cPath_array)) {
$categories_string .= '</b>';
}

if (tep_has_category_subcategories($counter)) {
$categories_string .= '-&gt;';
}

$categories_string .= '</a>';

if (SHOW_COUNTS == 'true') {
$products_in_category = tep_count_products_in_category($counter);
if ($products_in_category > 0) {
$categories_string .= '&nbsp;(' . $products_in_category . ')';
}
}

$categories_string .= '<br>';

if ($tree[$counter]['next_id'] != false) {
tep_show_category($tree[$counter]['next_id']);
}
}
?>
<!-- categories //-->
<tr>
<td>
<?php
$info_box_contents = array();
$info_box_contents[] = array('text' => BOX_HEADING_CATEGORIES);

new infoBoxHeading($info_box_contents, true, false);

$categories_string = '';
$tree = array();

$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
while ($categories = tep_db_fetch_array($categories_query)) {
$tree[$categories['categories_id']] = array('name' => $categories['categories_name'],
'parent' => $categories['parent_id'],
'level' => 0,
'path' => $categories['categories_id'],
'next_id' => false);

if (isset($parent_id)) {
$tree[$parent_id]['next_id'] = $categories['categories_id'];
}

$parent_id = $categories['categories_id'];

if (!isset($first_element)) {
$first_element = $categories['categories_id'];
}
}

//------------------------
if (tep_not_null($cPath)) {
$new_path = '';
reset($cPath_array);
while (list($key, $value) = each($cPath_array)) {
unset($parent_id);
unset($first_id);
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$value . "' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
if (tep_db_num_rows($categories_query)) {
$new_path .= $value;
while ($row = tep_db_fetch_array($categories_query)) {
$tree[$row['categories_id']] = array('name' => $row['categories_name'],
'parent' => $row['parent_id'],
'level' => $key+1,
'path' => $new_path . '_' . $row['categories_id'],
'next_id' => false);

if (isset($parent_id)) {
$tree[$parent_id]['next_id'] = $row['categories_id'];
}

$parent_id = $row['categories_id'];

if (!isset($first_id)) {
$first_id = $row['categories_id'];
}

$last_id = $row['categories_id'];
}
$tree[$last_id]['next_id'] = $tree[$value]['next_id'];
$tree[$value]['next_id'] = $first_id;
$new_path .= '_';
} else {
break;
}
}
}
tep_show_category($first_element);

$info_box_contents = array();
$info_box_contents[] = array('text' => $categories_string);

new infoBox($info_box_contents);
?>
</td>
</tr>




e vorrei aggiungere il riferimento ad un file css.


Adesso secondo me la riga dove bisogna intervenire è questa:

$categories_string .= '<a href="';

Modificandola così:

$categories_string .= '<a class="tx" href="';


Però purtroppo non va.
Dove sbaglio ?

Traxsung
23-08-2008, 12:51
Ragazzi scusate se vi tartasso, ma è veramente un'operazione illogica. Nel senso che ho applicata la stessa modifica su un altro script e va tutto perfettamente... mentre su questo non ne vuole sapere

Traxsung
24-08-2008, 10:22
sempre incasinato con questo problema.... Help me :muro: :muro: :muro:

Traxsung
25-08-2008, 13:16
Help :)

zoalord
25-08-2008, 17:26
Ciao,
intanto "non va", non dice molto sul problema che hai, potresti essere un po' più preciso?
L'interprete php restituisce errore, o piuttosto, come mi par di capire, gli attributi di quella classe definita nel css (perchè quella classe l'hai definita in un file css, vero??? ed il css l'hai referenziato/incluso nella pagina, vero???) non viene applicata come dovrebbe?
Intanto chiarisci questi punti e poi magari prova a vedere cosa viene restituito (come html) dal server, almeno ti puoi fare un'idea più precisa del problema.

Saluti.

Traxsung
25-08-2008, 18:29
Da php non ricevo nessun errore. Il file .css è naturalmente incluso e la classe l'ho creata io (in pratica attribuisce il colore del testo di colore bianco... è questo quello che voglio fare)

Questo di seguito è l'output in html



<tr><td><ul>

<li><a href=http://sito/Shop/index.php?cPath=10>prova</a></li><li><a href=http://sito/Shop/index.php?cPath=1>Praesent vestibulum</a></li><li><a href=http://sito/Shop/index.php?cPath=2>Molestie lacus aenean</a></li><li><a href=http://sito/Shop/index.php?cPath=3>Nonummy hendrerit mauris</a></li><li><a href=http://sito/Shop/index.php?cPath=4>Phasellus porta</a></li><li><a href=http://sito/Shop/index.php?cPath=5>Fusce suscipit varius mi</a></li><li><a href=http://sito/Shop/index.php?cPath=6>Cum sociis natoque penat</a></li><li><a href=http://sito/Shop/index.php?cPath=7>Magnis dis parturient</a></li><li><a href=http://sito/Shop/index.php?cPath=8>Ridiculus mus. Nulla dui</a></li><li><a href=http://sito/Shop/index.php?cPath=9>Fusce feugiat malesuada</a></li> </ul>
</td></tr>



Come si vede chiaramente la classe tx non viene proprio presa in considerazione

zoalord
25-08-2008, 18:46
puoi provare così:
'<a class=tx href="'

e così
'<a class=\"tx\" href="'

Ciao.