Donate Share

PHP Code Snippet Library

Tracker: Bugs

5 Edit snips with category - ID: 1602603
Last Update: Comment added ( nobody )

With this mod you can edit your snip, and change the category also!!

File "snips_edit.php"


In line 53 replace from

echo '<input type=hidden name=cats value='.$_GET['cats'].'>';

to

echo '<input type=hidden name=old_cats value='.$_GET['cats'].'>';



In line 47 AFTER

echo '<table width="600" border="0"><tr><td class="fr1">';

INSERT:

echo '<table width="600" border="0"><tr><td class="fr1">';
echo '<b>Select category:</b> &nbsp;<select name="cats">';
foreach($all_cats as $cat) {
if(strlen($cat) >1) {
echo "<option value=$cat>$cat</option>\n";
}
}

echo '</select></td></tr><tr><td class="fr2">';


In line 22 replace from

if(file_delete($_POST['cats'],$_POST['old_snip'])) {

to
if(file_delete($_POST['old_cats'],$_POST['old_snip'])) {


ENJOY
Normando

Sugestion: Any one can make a mod to include SUBcategories?


Normando Hall ( picsone ) - 2006-11-25 05:50

5

Open

None

Nobody/Anonymous

General

None

Public


Comments ( 2 )




Date: 2007-11-29 02:07
Sender: nobody

Logged In: NO

Thanks for sharing, you forgot one important thing, add it as following:
change:

foreach($all_cats as $cat) {
if(strlen($cat) > 1) {
echo "<option value=$cat>$cat</option>\n";
}
}

To:
foreach($all_cats as $cat) {
if(strlen($cat) > 1) {
$selected = ($_GET['cats'] && $_GET['cats'] == $cat) ? "selected" : "";
echo "<option value=$cat $selected>$cat</option>\n";
}
}

Otherwise the category will be changed to the first option everytime a
snippet is edited, and we don't want that.
enjoj


Date: 2006-11-26 19:13
Sender: picsone


In the mod of line 47 change the foreach loop to:

foreach($all_cats as $cat) {
if(strlen($cat) >1) {
if($_GET['cats']==$cat) {
echo "<option value=$cat selected>$cat</option>\n";
}else{
echo "<option value=$cat>$cat</option>\n";
}
}
}

to get the snips category preselected in the menu box.

Enjoy again.
Normando


Log in to comment.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.