TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 606
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 236
  • Total: 237
  • @rjen

How about a List Block

Started by rumboogy, March 07, 2008, 12:17:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rumboogy

I run a biker site, but I am sure this type of script could be used for any type of site that needs a list of people (sort of a roll call) attending a meeting, rally, wedding, party, concert, etc.

The list would be a way for a member to CLICK a button and their name be added to the list (no comments, just a name). Is this possible? Maybe a future feature.

Wally

JPDeni

I sorta have that now, although it's with a php article, combined with the custom profile fields mod.

You can see the result at http://www.morethanspike.com/index.php?page=29

I have several events that I'm tracking, so I have a table. If there was only one event at a time, it would be a list.

My guess is that this would be a highly specialized mod, and might be better as a block snippet rather than something that would be integrated into TP itself.

rumboogy

That looks like it would work for me...in fact, I could actually monitor several events at a time...is it on this site...or is it your own personal code. Thanks...looks very nice.

Wally

JPDeni

This is my own personal code. In the past, we would have people PM an admin to say they were going to be at an event and then the admin would add them to a list in the forum. Very tedious. So I worked out this code to let the users do it themselves.

The code is really ugly right now because it was just for myself and I didn't figure anybody else would ever see it. ;) I'll clean it up a bit and then post it. I'll likely move this to the Block Code Snippets board when I add the code.

I might get it done today, but no promises. :)

rumboogy

YOU Sir...are da MAN!!

Thank you.

Wally

JPDeni

#5
Actually, I'm da goil!! ;) But that's okay.

I ended up having a bit of time, so I went ahead and did it. Thanks for posting this. It's going to be a whole lot easier for me, now that I've made it neater.  Sometimes I need a push to make things better. :)

Here's the code, which goes into a php article. Or a center php block. It'll likely come out too wide for a side block.

Updated the script to include text fields and select fields as well as checkboxes.

global $db_prefix, $scripturl;

//////////////////////////////////////////////////////////////////
/////                    I M P O R T A N T                   /////
/////                                                        /////
////    This can only be used in conjunction with the        /////
////    Custom Profile Fields mod, which is available        /////
////    at the SMF site.                                     /////
/////                                                        /////
//////////////////////////////////////////////////////////////////

// List the Field IDs that you have set in the Custom Profile Fields
// in the order you want them displayed on the list.
$codes = array("SDIF","GSCo","Bord","Rift","Unio","Coll");

// Enter the field type for each field, , using the field IDs as the subscript
// If the field is a checkbox, enter 1
// if it's anything else, enter some other number

$field_type['SDIF'] = 1;
$field_type['GSCo'] = 1;
$field_type['Bord'] = 1;
$field_type['Rift'] = 2;
$field_type['Unio'] = 7;
$field_type['Coll'] = 1;

// List the full names of the events, in the same order as the field IDs above
$event_name[] = "San Diego<br>Indie Music Fest<br>29 Mar";
$event_name[] = "Grand Slam<br>12 - 13 Apr";
$event_name[] = "The Rift<br>26 Apr";
$event_name[] = "The Borderline<br>30 Apr";
$event_name[] = "Union Chapel<br>2 May";
$event_name[] = "Collectormania<br>3 - 4 May";

///////////////////////////////////////////////////////////////////////////////////

if (isset($codes[0])) {

  $return = '';
  $nbsp = "&nb" . "sp;";

  $event = array();
  $member = array();
  $link = array();

  foreach ($codes as $c)
    ($field_type[$c] == 1) ? $q[] = "(variable LIKE '$c' AND value <>0)" : $q[] = "(variable LIKE '$c' AND value NOT LIKE '')";
  $qr = implode("OR ",$q);

  $query = db_query("SELECT realName, variable, value, th.ID_MEMBER
                     FROM {$db_prefix}themes as th,{$db_prefix}members as mem
                     WHERE ($qr)
                         AND th.ID_MEMBER = mem.ID_MEMBER
                     ORDER BY realName", __FILE__, __LINE__);
  while ($row = mysql_fetch_assoc($query))
  {
    $event[$row['realName']][$row['variable']] = $row['value'];
    $member[$row['realName']] = 1;
    $link[$row['realName']] = '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>';
  }
  mysql_free_result($query);
  uksort($member, 'strnatcasecmp');
  $return .= '<center><table border="1">
                <tr align="center"><td>Member</td>';
  foreach ($event_name as $e)
    $return .= "<td>$e</td>";
  $return .= '</tr>';
  foreach ($member as $key => $value)
  {
    $return .= '<tr align="center"><td>'.$link[$key].'</td>';
    foreach ($codes as $c)
    {
      $return .= '<td>';
        if (isset($event[$key][$c]))
        {
         ($field_type[$c] == 1) ? $return .= '<center>X</center>' : $return .= $event[$key][$c];
        }
        else { $return .= $nbsp; }
      $return .= '</td>';
    }
    $return .= '</tr>';
  }
  $return .= '</table></center><br /><br />';
  }
  else
    $return = "There are no pending events at the moment<br /><br />";

echo $return;

echo 'If your name is already here and you would like to update your entry, just click your name on the list
and then click <b>Forum Profile Information</b> in the left column. Scroll down a bit and you will see the section
where you can enter the data.<br />If your name is not yet on the list, look up at the top right corner of the page and
click <b>Profile</b>, and then look for <b>Forum Profile Information</b> in the left column.<br /> If you have any problems
at all, feel free to ask for help.';



There's no error-checking, but there's only two things that you need to edit, so there shouldn't be too much of a problem. Notice with the event names, you can add line breaks and other html codes to make them print out however you want.

You also can certainly edit the instructions at the end.

rumboogy

Well...I am an IDIOT. Sorry JPDeni...Yes Maam...You are DA GOIL!! Thanks, I will try it and report back to you.

Thanks,

Wally

JPDeni

LOL!! That's okay. I'm used to it.

I'll be pleased to know how it works for you.

rumboogy

I am finishing it up right now...I will let you know within the next hour or less. So far...I like!

Wally

rumboogy

I LIKE's IT!!!

Here is the page:  http://www.arkansasbiker.net/index.php?page=41

I only have one question...what if I wanted to CENTER the table and instructions...is that possible?

Thanks...let me know what you think.

Wally

This website is proudly hosted on Crocweb Cloud Website Hosting.