Menu

#39 Adding Tagging feature to vtcal

open
Andre M
5
2009-01-21
2009-01-21
No

In inputeedata.inc.php, I retrieved results from a database, a list of possible tags to choose from and listed them as checkboxes on the form. So, the list is created dynamically. The user can select more than one tag. Here I have called the variable tags[] and I am loading all possible selections made by the user.

$results=$group->numRows();
for ($i=0;$i<$results;$i++) {
$groupname = $group->fetchRow(DB_FETCHMODE_ASSOC,$i);
$tagging[$groupname['fullname']]$i]=
$groupname['title'];
}

foreach ($tagging as $key => $value){
print "<tr><td><b>".$key."</b></td></tr>";
foreach ($value as $tagval){
echo "<td><input type=\"checkbox\" name=\"tags[]\" value=\"$key:$tagval\"";
echo "> $tagval </td>";
}
}

In changeeinfo.php I added the following code to retrieve the contents of the form element, tags[], and proceeded in setting the variable to $event['tags'] as the contents of the input in string form.

if(isset($_POST['tags'])){
$tags = $_POST['tags'];
$string = "";
foreach($tags as $key=>$val){
$string .= $val . ",";
}
setVar($event['tags'],$string,'tags');
}

I am able to echo the contents successfully on the screen so I know for sure that the data has been captured.

I then added code in inputvalidation.inc.php and confirmed that when I place a echo statement the contents are still present

elseif($type=='tags'){
if(!empty($value)){return TRUE;}
}

In functions.inc.php, is where I get the problem. I placed an echo in print_event() and the contents of $event['tags'] is there but when insertintoeventsql() is executed nothing is in $event['tags'] and I get a tags in undefined error in my error logs.

Any suggestions?

Discussion

  • Laura McCord

    Laura McCord - 2009-01-21

    Also, I forgot to mention the database modification. Basically, all I did was add an extra field, "tags", to both vtcal_event_public and vtcal_event. I know for sure that contents can be inserted into the table field because of my many failed variations of code I was able to get some stuff inserted into this field...just not the right result.

    Laura

     
  • Laura McCord

    Laura McCord - 2009-01-21
    • assigned_to: nobody --> amekkawi
     

Log in to post a comment.

MongoDB Logo MongoDB