Menu

#22 Edit snips with category

open
nobody
General (15)
5
2006-11-25
2006-11-25
No

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?

Discussion

  • Normando Hall

    Normando Hall - 2006-11-26

    Logged In: YES
    user_id=781149
    Originator: YES

    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

     
  • Nobody/Anonymous

    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

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.