Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Re: [SeanP] Hot Threads List...

Quote Reply
Re: [SeanP] Hot Threads List... In reply to
you really need to read the help section of your program.
Gossamer Forum Help
Table of Contents
Gossamer Forum Developers Guide : Enhancing Gossamer Forum
There are many different ways you can enhance Gossamer Forum. Plugins are the most advanced way and is a great way to share your addition with others. However, if you just need to add some code, or alter Gossamer Forum so it works for you, there are a couple different things you can do.
Running Custom Code:
Before you get into Plugins, you may not even need them! The template system provides a robust way of adding your own code to Gossamer Forum which will be safe from future upgrades!. It is strongly recommended that you not edit the source, but rather make your changes in separate modules or in template globals. You can do this in one of two ways:

1. Go to Build->Template Globals and you can add a perl subroutine. For instance, to display a list of the top 5 posts with most replies you could do: sub {
my $tags = shift;
my $post_db = $DB->table ('Post');
$post_db->select_options ('ORDER BY post_replies DESC', 'LIMIT 5');
my $sth = $post_db->select;
my @output;
while (my $post = $sth->fetchrow_hashref) {
push @output, $post;
}
return { post_loop => \@output };
}
The first argument is a hash ref of tags that are already available on this page. Your function can either return a hash ref making new tags available, or return HTML that will be displayed to the user. In our case we have created a new tag <%post_loop%> that will be a loop variable of 5 new posts. So you would do:
<%my_global_tag%>
<%loop post_loop%>
Post: <%post_subject%> has <%post_replies%> replies!
<%endloop%>

Assuming my_global_tag is what you save the above tag as.
2. Create your own module with functions, and reference it:
<%Yourmodule::somefunc%>
and it will run somefunc that should be found in Yourmodule.pm. When calling a function <%Module::function%>, it does not get passed any arguments. You can pass in your own arguments <%Yourmodule::somefunc ('This is my first argument', 'This is my second')%>. To get the hash of template tags available, simply call my $tags = GT::Template->tags; inside your code.
Adding Custom Fields:
Adding fields is easy in Gossamer Forum. To add a new field to the User table, simply click on Tools->User. It will show you a list of all the current columns. Do not remove system columns, but you can safely add new fields. Simply click on Add Column at the bottom. This will present you with the following options:
Column Name This is the name of the column, and must be a valid SQL name (so no spaces, etc.) Column Type This is a select list of what type of data you will store. If you need more then 255 characters, you should use a TEXT field. Column Size This is the length of the field and is only required for CHAR types. Column Values
(Only for ENUM fields)
If you are using an ENUM (enumerated) type, then you need to enter the values here. One value per line. For instance if you wanted to add a column Status that could have values 'Cool', 'New', 'Popular', 'Reviewed' only, then you would enter those values her, one per line. Not Null Set to Yes if the user must enter a value, if set to no, the column can be left blank. Default Enter the default value here, this will be what is shown when the user clicks on add. Form Display If your column is named foo_bar then you can enter a pretty name that is used when displaying the column (such as 'My New Column'). Form Type A select list of what type of form you want to use to display this field: checkboxes, radio buttons, textareas, etc. Form Size The SIZE attribute of the form, this determines how large the form appears in the admin. Form Names
(Stored in Database)
If the form type is a select or checkbox, this list controls what names are stored in the database. Form Values
(Displayed on Form)
If the form type is a select or checkbox, this list controls what values are displayed to the user. Form Regex You can enter a regular expression that all input must pass before being submitted. Search Weight This controls whether the field is searchable by the user. The higher the number, the more important the result is.
When you hit submit, the column will automatically appear in your Admin, and be available on your templates as <%ColumnName%>. Table of Contents



Sandra Roussel
Chonsa Group Design - Fresh Start Housing
Subject Author Views Date
Thread Hot Threads List... SeanP 6693 Feb 18, 2005, 11:51 AM
Thread Re: [SeanP] Hot Threads List...
SandraR 6466 Apr 14, 2005, 2:58 PM
Post Post deleted by SeanP
SeanP 6468 Apr 15, 2005, 12:37 PM
Thread Re: [SandraR] Hot Threads List...
webslicer 6455 Apr 19, 2005, 8:33 PM
Thread Re: [webslicer] Hot Threads List...
agaffin 6337 Jun 21, 2005, 11:55 AM
Thread Re: [agaffin] Hot Threads List...
webslicer 6373 Jun 22, 2005, 1:05 AM
Thread Re: [webslicer] Hot Threads List...
agaffin 6344 Jun 22, 2005, 10:20 AM
Thread Re: [agaffin] Hot Threads List...
webslicer 6269 Sep 9, 2005, 5:44 AM
Post Re: [webslicer] Hot Threads List...
Jobu 6004 Aug 25, 2006, 7:37 AM
Thread Re: [agaffin] Hot Threads List...
Jobu 5961 Sep 2, 2006, 6:56 AM
Thread Re: [Jobu] Hot Threads List...
tandat 5959 Sep 2, 2006, 7:58 AM
Post Re: [tandat] Hot Threads List...
Jobu 6004 Sep 2, 2006, 7:59 AM