The vB Geek

Go Back   The vB Geek > vB Geek Products > Geek Article and Review System

Geek Article and Review System GARS is the mega popular system for turning forums into articles, tutorials, or even reviews.

Advertisement
  Learn how to remove ads

Reply
 
Thread Tools Display Modes
  #1  
Old 02-27-2006, 05:58 AM
Marris Marris is offline
Junior Member
 
Join Date: Feb 2006
Posts: 23
Geek Article and Review System License Holder 
Question How to add a new date field?

After reading through the documentation and looking through some of the module code, I haven't had much luck trying to create a module to add an additional date field.

First of all, is there an easy way to do this, like "Add Field" type "date" somewhere?

If not, then am I correct in trying to create a new module for this field, or can this be done with template changes?

I want to create one field named "Release Date" with a user input, validated date (mm-dd-yyyy or mm/dd/yyyy). It doesn't necessarily have to be a part of its' own module block, so it could just be displayed under the Article Title.

It does, however, need to be a valid date variable, so I can eventually use it to sort by date or list X number of items based on this date field.

Any advice is appreciated. Thank you.
Reply With Quote
  #2  
Old 02-27-2006, 07:35 AM
The Geek's Avatar
The Geek The Geek is offline
Senior Member
 
Join Date: Aug 2005
Posts: 6,717
Geek Article and Review System License Holder GeekMart License Holder Geek Auto-Linker Pro License Holder Geek Advertising Banner License Holder Geek Gazette License Holder 
Default

Hey Marris, I am looking to impliment a way for people to add extra fields asin the user profile manager, however it wasnt really designed for that feature.

Did you read the tutorials in the GARS section? There are 2 on creating custom modules.
Reply With Quote
  #3  
Old 02-27-2006, 05:31 PM
Marris Marris is offline
Junior Member
 
Join Date: Feb 2006
Posts: 23
Geek Article and Review System License Holder 
Default

Quote:
Originally Posted by The Geek
Hey Marris, I am looking to impliment a way for people to add extra fields asin the user profile manager, however it wasnt really designed for that feature.

Did you read the tutorials in the GARS section? There are 2 on creating custom modules.
Thanks. Yes, I was working from your module tutorials, but had trouble getting a valid date format, rather than a simple string input. I'll take another whack at it today.

A system for new fields like the User Profile Manager would be great. That would probably allow people to create 90% of the options they need without touching the module code.
Reply With Quote
  #4  
Old 02-27-2006, 05:38 PM
The Geek's Avatar
The Geek The Geek is offline
Senior Member
 
Join Date: Aug 2005
Posts: 6,717
Geek Article and Review System License Holder GeekMart License Holder Geek Auto-Linker Pro License Holder Geek Advertising Banner License Holder Geek Gazette License Holder 
Default

yea, I agree. Truth be told, something like that didnt ever cross my mind while I was creating GARS. I figured it was easy enough to simply capture the data via the module system however its pretty obvious that only those familiar with html, PHP and GARS can do it as easy as they should be able to.
A custom profile field table for threads is exactly what the dr. ordered in this situation and would allo me to do things like the auction system much easier (yes, there is a GARS enabled auction system in the works. Please lord dont ask me for an ETA )
Reply With Quote
  #5  
Old 02-27-2006, 05:58 PM
Marris Marris is offline
Junior Member
 
Join Date: Feb 2006
Posts: 23
Geek Article and Review System License Holder 
Default

Quote:
Originally Posted by The Geek
A custom profile field table for threads is exactly what the dr. ordered in this situation and would allo me to do things like the auction system much easier (yes, there is a GARS enabled auction system in the works. Please lord dont ask me for an ETA )
Auction system...don't tease us like that. GARS obviously has unlimited potential to be the Swiss Army Knife of extending the functionality of vBulletin sites.

I just need to get a better handle on PHP/MySQL to get it to serve the requirements of my site design.
Reply With Quote
  #6  
Old 03-03-2006, 07:18 AM
Marris Marris is offline
Junior Member
 
Join Date: Feb 2006
Posts: 23
Geek Article and Review System License Holder 
Default

Well, I finally hammered out a basic date module. It takes a date value input in the numeric format MM/DD/YYYY, then displays the date in the GARS_mod_container.

There is rudimentary validation of the numeric input format, but it doesn't check if the date is within any realistic limits. If the input is left blank, the module displays "n/a".

Here's the code, in case it can be of use to someone else:

PHP Code:
<?php
if ($stage == "edit")
{
if (
$values['datesimp'] == "") {
    
$tempdate "";
   } else {
   
$tempdate date("m/d/Y",$values['datesimp']);    
  }
    
$output .= "            <fieldset class=\"fieldset\">
                        <legend>Release Date</legend>
                        <div style=\"padding:3px\">
                        Release Date in MM/DD/YYYY (Month/Day/Year) numeric format:<br />
                        <input type=\"text\" class=\"bginput\" name=\"custom1[datesimp]\" id=\"GARS_datesimp\" value=\"" 
$tempdate "\" size=\"11\" maxlength=\"10\" tabindex=\"1\" />
                        </div>
                    </fieldset>"
;
}
elseif(
$stage == "persist")
{
$datesimp $this->vb->GPC['custom1']['datesimp'];
if (
$datesimp == ""){
  
$values['datesimp'] = $datesimp;
  }    else {
      
if (!
eregi('^[0-9]{1,2}/[0-9]{1,2}/[0-9]{4}$'$datesimp)) {
                                eval(
standard_error(fetch_error('GARS_invalid_date_format')));
    } else {
      
    
$values['datesimp'] = strtotime($datesimp);
    }
  }
}
elseif(
$stage == "display")
{
$title "Release Date";
if (
$values['datesimp'] == "") {
    
$bits "<tr><td class=\"alt1\" align=\"center\">n/a</td></tr>";
} else {
$date_formatted date("m/d/Y",$values['datesimp']);
$bits "<tr><td class=\"alt1\" align=\"center\">" $date_formatted "</td></tr>";
 
}
eval(
'$output.="' fetch_template('GARS_mod_container') . '";');
}

?>
It also requires a new phrase:

product: GARS LITE

type: Error mesasges

var name: GARS_invalid_date_format

CONTENT:
PHP Code:
ErrorRelease Date not in valid format!
<
div align="center"><input type="button" class="button" value="Go Back" title="" tabindex="1" onclick="window.location='javascript:history.back(1)';"/></form></div

Last edited by Marris; 03-03-2006 at 07:22 AM..
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
date selector custom field won't allow dates before 1970 Mark Seifert Geek Article and Review System 1 06-30-2009 06:00 PM
Custom field, Date Slector gldtn Geek Article and Review System 2 01-29-2008 12:44 PM
Date Field errors indie Geek Article and Review System 2 01-28-2008 07:38 AM
Date saying December 31, 1969 for info block & date problem with thread preview alldoulas Geek Gazette 0 08-04-2007 04:48 PM
Release Date jluerken Geek Article and Review System 1 10-24-2005 10:14 AM


All times are GMT. The time now is 09:32 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.