Navigation
  •    
Forum TAESS Networks Problem mit "Icon Sort"
Hey (:
Ich habe mir ein Icon Sort Script installiert. Klappt auch alles so weit aber ich hätte gerne die Navigation als Div (Momentan versuch ichs mit Iframe): http://blackout.bplaced.net/Unbenannt.jpg

Ich verzweifel total weil es einfach nicht klappt. Es soll sich auch im mainframe öffnen. Das ist der Code:

<?php
echo '<ul id="iconmenu">';
foreach ($cats as $value) {
$catname = str_replace('_', ' ', $value);
echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?cat=' . $value . ' ">' . $catname . '</a>';
if ($getcount) {
$icons = array();
$getcount = opendir($catdir . '/' . $value);
while (($icon = readdir($getcount)) !== false) {
if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
$icons[] = $value;
}
}
$count = count($icons);
if ($count == 1) {
echo ' (' . $count . ' icon)';
} else {
echo ' (' . $count . ' icons)';
}
}
echo '</li>';
}
echo '</ul>';
}

Ich hoffe jemand kann mir helfen!

Antworten
Hoi,

um daraus eine Select-Box zu machen...

Zeile 2, aus:
Code


echo '<ul id="iconmenu">';
wird:
Code


echo '<form action="" method="get"><select name="cat">';

Zeile 5, aus:
Code


echo '<li><a href="' . $_SERVER['PHP_SELF'] . '?cat=' . $value . ' ">' . $catname . '</a>';
wird:
Code


echo '<option value="' . $value . '">' . $catname . ' '

Zeile 21, aus:
Code


echo '</li>';
wird:
Code


echo '</option>';

Zeile 23, aus:
Code


echo '</ul>';
wird:
Code


echo '</select></form>';

PS: Ich übernehme keine Haftung, ob das auch alles so fehlerfrei ist (:

Erstmal danke für die Hilfe (:
Aber jetzt steht bei mir:


Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in /users/blackout/www/icon/icons.php on line 166

Das ist also der neue Code:

Code


<?php
echo '<form action="" method="get"><select name="cat">';
foreach ($cats as $value) {
$catname = str_replace('_', ' ', $value);
echo '<option value="' . $value . '">' . $catname . ' '
if ($getcount) {
$icons = array();
$getcount = opendir($catdir . '/' . $value);
while (($icon = readdir($getcount)) !== false) {
if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
$icons[] = $value;
}
}
$count = count($icons);
if ($count == 1) {
echo ' (' . $count . ' icon)';
} else {
echo ' (' . $count . ' icons)';
}
}
echo '</option>';
}
echo '</select></form>';
}

Du musst dein echo schon mit 'nem ; schließen.
Und ganz unten ist noch 'ne geschwungene Klammer zu viel (falls weiter oben nicht noch irgendwo Code sein sollte).
Signatur von Eli

So ich hoffe ich hab alle Fehler verbessert. Jetzt steht bei mir aber immernoch eine Fehlermeldung: Parse error: syntax error, unexpected $end in /users/blackout/www/icon/icons.php on line 285

Ich weiß nicht woran das liegen könnte (bin noch nicht so erfahren im PHP Bereich)

Der Code sieht jetzt so aus:

Code


<?php
echo '<form action="" method="get"><select name="cat">';
foreach ($cats as $value) {
$catname = str_replace('_', ' ', $value);
echo '<option value="' . $value . '">' . $catname . ' ';
if ($getcount) {
$icons = array();
$getcount = opendir($catdir . '/' . $value);
while (($icon = readdir($getcount)) !== false) {
if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
$icons[] = $value;
}
$count = count($icons);
if ($count == 1) {
echo ' (' . $count . ' icon)';
} else {
echo ' (' . $count . ' icons)';
}
}
echo '</option>';
}
echo '</select></form>';
}

Das ist auch der einzige Teil den ich verändert habe also muss da ja irgendwo noch ein Fehler sein oder?

Ist das der ganze PHP-Teil?
Irgendwie wäre ne Nummerierung cool...der Code-Tag hier hat das nicht :(
Ich weiß nicht, irgendwie kommt mir Zeile 285 spanisch vor, weil du vorhin 'nen Fehler in der Zeile 166 hattest und jetzt 120 Zeilen weiter unten...?
Die Zeile ist gar nicht mehr in dem Ausschnitt - oder hast du was verschoben?
Ich sehe jedenfalls kein "unexpected $end" (= wahrscheinlich geschweifte Klammer fehlt zum Schließen).
Wie gesagt, in dem Abschnitt isses nicht, denn der funktioniert jetzt.
Signatur von Eli

Also das hier ist der komplette Code:

Code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>BLACKOUT</title>
<style type="text/css">
body { background-color: #3b3b3b; }
body, select, option { color: #000000; font: 11px tahoma; }
i { font-size: 10;
font-family: verdana;
font-weight: italic;
color: #ebbfa2;
text-decoration: none;}

u { font-size: 10;
font-family: verdana;
color: #bfbfbf;
border-bottom: 2px solid;
border-color: #77a1ac;
text-decoration: none;}

b { font-size: 10;
font-family: century gothic;
color: #348a8f;
text-decoration: none;}


a:link{color:#ebbfa2; letter-spacing: 1; text-decoration: none; font-family: Verdana; font-size: 10px;}
a:visited {color:#ebbfa2; letter-spacing: 1; text-decoration: none; font-family: Verdana; font-size: 10px;}
a:active{color:#ebbfa2; letter-spacing: 1; text-decoration: none; font-family: Verdana; font-size: 10px;}
a:hover {color:#77a1ac; letter-spacing: 1; font-weight: underline; text-decoration: none; font-family: Verdana; font-size: 10px;}

#iconmenu{
target: mainframe;
}

.pagemenu a, .pagemenu a:visited, .pagemenu a:active {
margin: 2px 2px 0px 0px;
padding: 5px;
text-align:center;
line-height:40px;
font-size:10px;
-moz-border-radius:5px;
background: #464646;

}

.pagemenu a:hover {
margin: 2px 2px 0px 0px;
padding: 5px;
text-align:center;
line-height:40px;
font-size:10px;
-moz-border-radius:5px;
background: #464646;
}


ul { list-style-type: square; list-style-position: inside; padding: 0px; margin-left: 0px; }
h1 {
font-weight: bold;
font-family: century gothic;
font-size: 18px;
text-align: right;
color: #348a8f;
letter-spacing: 3px;
text-transform: uppercase;
margin-bottom:5px;}

h1:first-letter {
color:#000000; }
.credit { font-size: 10px; }
</style>
</head>
<body>

<!-- Edit the header above or replace it with your own. -->

<?php
/*

ICON SORT
------------------------------------------------
A Quick and Easy PHP Icon Management Script by Julie (http://new-place.org/)

This script is free for non-commercial use and may be modified for personal use. Please do not distribute modified copies of this script without my permission. You may not sell this script or modified versions of it under any circumstances.

As provided, this script is valid XHTML 1.0 transitional. The only requirement is PHP support (no database needed)!


UPDATES
------------------------------------------------
February 7, 2005 - Fixed the pagination to work with register_globals off. Added file setup example to the instructions and tidied up the code in general.

September 2, 2005 - Two new features added! It is now possible to display the icon count per category on the menu, and/or to paginate the individual category pages. There are three new config variables.


SETUP INSTRUCTIONS
------------------------------------------------
Icon Sort can be installed in a new directory created specifically for this script, or you can put it in an existing directory that holds other files. You can safely rename this file to whatever you'd like it to be called!

1.) Create a folder named "categories" in the same directory where this file will go. If you don't want to call it "categories," edit the $catdir config variable (below the instructions) to the name you choose.

2.) Inside the "categories" folder, create a folder for each category of icons you want. If there are spaces in the category name, replace them with underscores. For example, instead of "Veronica Mars" use "Veronica_Mars." (Replacing spaces with underscores is optional, but recommended, as it creates cleaner, more compatible links. The underscores will not show up on the page.) Upload your icons into their respective category folders.

An example of the setup:
yoursite.com/icons.php <- this file
yoursite.com/categories/ <- the categories folder
yoursite.com/categories/Veronica_Mars <- the individual category folders go inside that folder

3.) If desired, change the "sort" config variable (below the instructions) from 'first' to 'last' if you prefer new icons to be added to the bottom of the page. By default, the newest icons added to a category are shown first on the category page.

4.) Edit the "getcount," "perpage," and "divider" variables as desired. None of them has to be changed for the script to work, but they allow you to customize the setup.

5.) Edit or replace the header and footer at the top and bottom of this file to fit your site. Edit or remove the paragraph above the menu (scroll down and find "<!-- Content Above Menu -->"). Upload this file. That's it!


CUSTOMIZATION AND SUPPORT
------------------------------------------------
There are a few built in CSS styles to help you style your page. The menu <ul> is id="iconmenu", the category page menu <p> is class="pagemenu", the <p> that holds the icons is class="icons", and the <p> that holds the credit to my site is class="credit".

If you are having a problem, send in a contact form at my site (http://new-place.org/) or post at the CodeGrrl forums (http://codegrrl.com/) and I will try to help.


CONFIG VARIABLES
------------------------------------------------*/
$catdir = 'categories'; // the icon categories folder (see step 1)
$sort = 'first'; // set 'first' to show newest icons first, 'last' to show newest icons last
$getcount = true; // true shows the icon count per category in the menu, and false turns it off
$perpage = 20; // the number of icons shown on each page (set to a really high number to turn off pagination)
$divider = '&nbsp;'; // the divider between the numbers and front/back arrows in the page navigation


// DO NOT EDIT THE PHP BELOW THIS LINE. Scroll down to edit the text above the menu, and to add your footer.
// ----------------------------------------------

// get category folders and sort
if (!file_exists($catdir)) {
echo 'Error! The folder named <strong>' . $catdir . '</strong>, as specified in the config, does not exist in this directory. The value of the variable $catdir must match the name of the created folder (case-sensitive), and that folder must be in this directory for the script to work. Create the folder and put the individual icon category folders inside it.';
exit();
}
$getfolders = opendir($catdir);
while (($file = readdir($getfolders)) !== false) {
if (($file != '.' && $file != '..') && (is_dir($catdir.'/'.$file))) {
$cats[] = $file;
}
}
if (!$cats) {
echo 'No category folders were found inside the folder named <strong>' . $catdir . '</strong>. Create your individual category folders inside that folder and the menu will appear.';
exit();
}
natcasesort($cats);

// build main menu
if ((!$_GET['cat']) || (!in_array($_GET['cat'], $cats))) {
?>


<?php
echo '<form action="" method="get"><select name="cat">';
foreach ($cats as $value) {
$catname = str_replace('_', ' ', $value);
echo '<option value="' . $value . '">' . $catname . ' ';
if ($getcount) {
$icons = array();
$getcount = opendir($catdir . '/' . $value);
while (($icon = readdir($getcount)) !== false) {
if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
$icons[] = $value;
}
$count = count($icons);
if ($count == 1) {
echo ' (' . $count . ' icon)';
} else {
echo ' (' . $count . ' icons)';
}
}
echo '</option>';
}
echo '</select></form>';
}

// get icons and sort
if (in_array($_GET['cat'], $cats)) {
$icons = array();
$geticons = opendir($catdir.'/'.$_GET['cat']);
while (($icon = readdir($geticons)) !== false) {
if (eregi(".jpg$|.jpeg$|.gif$|.png$|.bmp$", $icon)) {
$icons[] = array("name" => $icon, "modified" => filemtime($catdir . '/' . $_GET['cat'] . '/' . $icon));
}
}
$count = count($icons);
if ($count > 0) {
function modcmp($a, $b) {
return strcmp($a['modified'], $b['modified']);
}
usort($icons, 'modcmp');
if ($sort == 'first') {
$icons = array_reverse($icons);
}

// show category name and total icon count
$catname = str_replace('_', ' ', $_GET['cat']);
echo '<p align=center><b>' . $catname . ': ' . $count;
if ($count == 1) {
echo ' icon';
} else {
echo ' icons';
}
echo '</b></p>';

// configure pagination
if ((!$perpage) || ($perpage < 1) || (!is_numeric($perpage))) {
$perpage = 20;
}
$pagecalc = ($count / $perpage);
$pagecount = ceil($pagecalc);
$page = $_GET['page'];
if (($page > $pagecount) || ($page == '0')) {
$start = 0;
} elseif (!$page) {
$start = 0;
$page = 1;
} elseif (!is_numeric($page)) {
$start = 0;
$page = 1;
} else {
$start = (($page * $perpage) - $perpage);
}
$pagearray = array_slice($icons, $start, $perpage);

// if there is more than one page, show the page menu
if ($pagecount > 1) {
if (($page <= $pagecount) && ($page > 1)) {
$backpagecalc = ($page - 1);
$backpage = '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $backpagecalc . '">&laquo;</a> ' . $divider;
}
if ($page < $pagecount) {
$nextpagecalc = ($page + 1);
$nextpage = $divider . ' <a href="?cat=' . $_GET['cat'] . '&amp;page=' . $nextpagecalc . '">&raquo;</a>';
}
echo '<p class="pagemenu">Pages: &nbsp;' . $backpage . ' ';
$i = 1;
while ($i <= $pagecount) {
$pagespanstart = ((($i * $perpage) - $perpage) + 1);
$pagespanend = ($i * $perpage);
if ($i == $pagecount) {
if ( $i == $page) {
echo $i;
} else {
echo '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $i . '">' . $i . '</a>';
}
} else {
if ($i == $page) {
echo $i . ' ' . $divider . ' ';
} else {
echo '<a href="?cat=' . $_GET['cat'] . '&amp;page=' . $i . '">' . $i . '</a> ' . $divider . ' ';
}
}
$i++;
}
echo ' ' . $nextpage . '</p>';
}

// show the icons
echo '<p class="icons">';
foreach ($pagearray as $value) {
$iconsize = getimagesize($catdir . '/' . $_GET['cat'] . '/' . $value['name']);
echo '<img src="' . $catdir . '/' . $_GET['cat'] . '/' . $value['name'] . '" ' . $iconsize[3] . ' alt="" /> ';
}
} else {
echo '<p>There are no icons in this category.';
}
echo '</p><p>&laquo; <a href="' . $_SERVER['PHP_SELF'] . '">back</a></p>';
}
?>

<!-- You may remove this credit for stylistic purposes, but a link back on your credits page or elsewhere is appreciated. -->
<p class="credit">Powered by <a href="http://new-place.org/scripts/" target="_blank">Icon Sort</a></p>

<!-- Edit the footer below above or replace it with your own. -->
</body>
</html>

Ich weiß nicht wie ich das mit der Nummerierung machen soll ich hab kein Programm dafür (hatte mal Frontpage aber das ist abgestürzt). Arbeite immer mit dem normalen Editor

Mach mal vor das letzte ?> eine }.
Tipp: Code einrücken, dann behält man den Überblick (als ob ich's machen würde xD)
Signatur von Eli

Jaaa jetzt geht es danke (:
Aber dafür sieht meine Selectauswahl jetzt so aus: http://blackout.bplaced.net/Unbenannti.jpg XD

Und meine Ordner werden plötzlich nicht mehr angezeigt Oo

Tjoa, dann ist wohl doch irgendwas falsch, vielleicht gehört die Klammer woanders hin.
Was hat es denn mit dem Icon Script auf sich?
Ich hab zwar schon die Seite vom Ersteller besucht, aber ich schnall nicht was das darstellt. Was macht man damit (also mit den Icons, wenn man sie ausgewählt hat)?
Signatur von Eli

Also, (ich hoffe ich hab die Frage richtig verstanden XD), dieses Script soll sowas wie eine Icon Gallery sein. Man erstellt einen Unterordner mit dem Namen "categories". Wenn ich in diesem Unterordner weitere Ordner erstelle dann sind das die Icon Kategorien. So wie hier: http://new-place.org/demo/iconsort/
Er stellt man einen Ordner namens Veronica_Mars und tut in diesen Ordner Icons werden da auch unter Veronica Mars angezeigt. Man kann das also praktisch wie bei einem ACP ordnen. Jetzt kam ich aber auf die Idee das alles ein wenig anders dar zustellen. Unzwar hab ich den Ordner "All" erstellt. Diese Kategorie soll sozusagen als Index dargestellt werden. Das hat auch alles soweit funktioniert. Hab das einfach als Iframe. Aber das Verzeichnis wollte ich als Div (momentan ist es noch Iframe) und Selectauswahl haben. Ich hab das mit dem Select einfach nicht hinbekommen und ich kriegs auch nicht hin dass z.B. die Seite "Katy Perry" sich im Mainframe öffnet.
Ich hoffe das wars was du wissen woltest XD

Joa, jedenfalls ist irgendwo eine Klammer nicht zu. Aber wo ist die Frage.
Signatur von Eli

Lädt...
 SchließenHinweis: Um Dir ein besseres Nutzererlebnis zu bieten, werden von uns sogenannte Cookies gesetzt. Durch die Nutzung unserer Website stimmst Du dem zu. Nähere Informationen findest Du in unserer Datenschutzerklärung.