PDA

View Full Version : Custom Fields


The Geek
06-05-2006, 07:35 PM
Here I am going to cover the basics of creating Custom Fields in GARS 2.0

Please note that this documentation was created for GARS 2.0 Beta 2. It may not be 100% up to date and things may change as future versions come out.

Step 1
Create a custom field
393

To create a custom field, click admincp->gars->custom fields->add new
Choose the type of custom field you want to create. Please note that you can not change the type after you created it - however you can always delete and create another!

Here is a quick overview of each type at time of writing this:


text - A one line text box.
Large text - a large text area
Whole number - A one line text box that only accepts whole numbers
Date selector - allows entering of dates
Single check box - um. Guess? That's right a single check box!
Check Boxes - allows you to create a group of tick boxes
Radio Buttons - Create a group of radio buttons
Select box - allows a drop down combo box.
Snipped URL - Allows users to enter in a URL, but display will be snipped after x amount of characters.
Thumbnail to original image - allows users to upload an image. When displayed, they only get a thumbnail that when clicked, will open the browser to the original image.
Thumbnail to URL - Allows user to upload an image which is thumb nailed. User also enters a URL. When you click on the thumbnail, it takes you to the URL.Once you choose which field type you want, you will be able to enter the settings for the field.

389

Title What you want to call it. It also appears above the custom field when a user is creating/editing their GAR
Description A short description for the field. It too appears above the custom field when creating/editing an item.
Display Order The, er - order it displays. A lower number makes it display earlier :)Other settings should be self explanatory. However I'm sure Ill be writing info on each type later.

Step 2
Assign the custom field to one or more types.

392

Edit the types you want to assign the custom field to (admincp->gars->types).
At the bottom of the page, you will see all available types that you can assign. Assign by ticking the box next to the custom field and clicking Save.

388

From that stage, the fields will be available when editing and creating a new GARS controlled thread.


Step 3
Displaying the values of your custom fields

Make sure you have the custom_fields.php module registered.

go to admincp->gars->modules
Check the bottom section (Registered modules) to see if you have Custom Fields there.
If not, then add it by clicking Register New Module and adding the following settings:

title: Custom Fields
file: custom_fields.php
templates: GARS_custom_container, GARS_custom_row,GARS_custom_date,GARS_custom_input ,GARS_custom_text,GARS_custom_textarea,GARS_custom _thumbnail

Then click Save.

This will make the custom fields module available to your module sets.

Step 4
Add Custom Fields to your module sets

390
Edit a module set making sure you are on the showthread page.
Scroll to the bottom of the page and in the left selection box, choose Custom Fields, then the position you want to place it.
Click Save and the Custom Fields module will be in position.
Edit the Custom Fields module settings page by clicking it's name (or by selecting edit from the drop down menu next to its name).

391

Here you can edit the title for the module box when it displays. You can also select which Custom Fields display along with an optional caption.
You can also overwrite the templates GARS uses to display the custom fields. Leave the template settings blank for the default.

[B]Viola!
394
Whoop there it is...

benj
08-20-2006, 04:00 PM
when making a custom template for a field.whats the varible for the value of the field ?

The Geek
08-21-2006, 08:41 AM
Sorry, you lost me :)

benj
08-21-2006, 09:56 AM
when adding a custom field to the custom module it offers you the option to use a template ? how do thouse templates work ?

The Geek
08-21-2006, 11:36 AM
What it does is allow you to override the default template for displaying the item or hosing the module.

That gives you the ability to do something far cooler then simply showing the text results. The standard results for that module are displayed in GARS_custom_row.

beduino
10-15-2006, 05:00 AM
this tutorial is very clear and useful,
but my first tentative fails...when i will display in my personal module set - he don't appears!
what i do wrong? :confused:
tks
beduino

The Geek
10-15-2006, 05:56 AM
If the custom fields appear when creating/editing a thread but do not appear when viewing a thread... the most common culprit is your Custom Fields module settings.

Edit the module set for the type in question.
On the showthread page of the module set, click the Custom Field module (if the module isnt there, you need to add it)
Tick each field you want to display.

Save it and bob should be your uncle.

HTHs

beduino
10-15-2006, 12:56 PM
Well,
I'm learning the use of GARS.:o
In fact the 'custom fields' is to author, and no to comments of viewers and users. IMHO this mod is one of better licences I have ! :)
All the best,
Beduino
ps. a lot of questions will be come :rolleyes:

Julian
11-02-2006, 06:59 PM
I have another challange: I want to display the Value of the custom-field inside of another template. Well, to be clear: Behind the picture displayed should be a link and a part of the link is the custom-field.

The custom-field is named "test" and the content of one of the posts is "12345". Now I want to have a link in the postbit which is built up like this:

www.abcde.de/index.php&test=12345&somethingelse

I´d like to get this in the way of:
<a href="www.abcde.de/index.php&test="+"$table[test]&somethingelse" >$vbphrase[blabla]</a>

Is this possible?

Best wishes, Julian!

The Geek
11-04-2006, 01:10 AM
It should be fine. instead of $table[test], try $post[gars1] (where gars1 is the field name)

HTHs

trana
11-04-2006, 09:29 PM
Two questions.

How can I create a custom large text field that has some sense of formatting (i.e. carriage returns, maybe a bbcode editor?) Right now when I put in a list of names on separate lines it joins them all together.

Also, is there any way to create a custom field that would act like a table? For example, I want people to use the first post (i.e. the article) to keep tabs on certain things, so they need to list:

UserID1, items requested, total due, paid or not?
UserID2, items requested, total due, paid or not?
UserID3, items requested, total due, paid or not?

As people send their payments or update their orders the owner goes back and updates this custom field. If a custom field could support bbcode editing then maybe I can use the preexisting bbcode table hack.

Any suggestions would be appreciated!

Neutral Singh
11-05-2006, 01:36 PM
Please have a look here. http://www.sikhbusiness.net/culture-society/8863-astronomical-society-host-viewing-transit-mercury-idaho-statesman.html#post8871

Why no heading is showing up for customer field? The value is showing though i.e. 10.

Any clue.

The Geek
11-05-2006, 03:25 PM
Hi Trana,

You cant use the vB editor to enter bbcode into a text area, however you can set the custom field to parse bbcode. In other words, if you set it to parse bbcode then it will act like an editor (with line breaks, formatting code, etc...).

To customize the contents, the easiest thing to do would be to create a custom field row and container. If you edit the Custom Fields module in your module set, you will see that you can specify a value for the custom row and also one for the container. This allows you to override the GARS defaults and lay it out as you would like.

I hope that helps!

Neutral, check out the settings for the custom fields module in your module set. It allows you to specify a title for the box.

HTHs!

trana
11-05-2006, 04:17 PM
Hi Trana,

You cant use the vB editor to enter bbcode into a text area, however you can set the custom field to parse bbcode. In other words, if you set it to parse bbcode then it will act like an editor (with line breaks, formatting code, etc...).

To customize the contents, the easiest thing to do would be to create a custom field row and container. If you edit the Custom Fields module in your module set, you will see that you can specify a value for the custom row and also one for the container. This allows you to override the GARS defaults and lay it out as you would like.

I hope that helps!

That helps, but what you are suggesting is to create a whole bunch of customer text fields? Thats not going to scale well if I keep adding names to the lists.

trana
11-05-2006, 04:20 PM
Also, to be clear, I don't need every bit of data to hit a separate custom field. I am fine with addinging everything on a space formatted line by line process as long as the field will accept at least a hard return for formatting. Know what I mean?

trana
11-05-2006, 04:33 PM
I went back and tried to use the bbcode hack from .org to make this work. It seems to work find in the body of the message but not in the custom field.

This will give you some idea of what it looks like.

The Geek
11-08-2006, 12:55 AM
hmmm... There really is no reason why the bbcode wouldnt work in the custom text field, however all I am recommending is to change the default row template... you may not even have to change the container template... can you mock up what you had in mind?

trana
11-08-2006, 02:19 AM
The image I attached in my last post has the same text posted in a custom text box and the message content. The custom text box does not seem to display the bbcode.

The Geek
11-08-2006, 01:48 PM
I would have to crack open his code to find out why it isnt parsing the contents. I can only assume it doesnt parse like normal bbcode does then. Ill download it and try it out

trana
11-09-2006, 12:17 AM
Well, in addition to that bbcode, I can't get a hard return to work. If I put thinks on separate lines that should work in the field display right?

The Geek
11-10-2006, 04:23 AM
is it parsing bbcode? i.e. if you put a smilie in, does it appear?

trana
11-10-2006, 04:36 AM
Nope. None of them work.

The Geek
11-10-2006, 04:37 AM
And it is set in your custom fields setting to parse bbcode?

trana
11-10-2006, 04:40 AM
I'm going to go find a nice hammer to hit myself over the head. Thxs.

kafi
11-16-2006, 07:32 PM
Yup this custom fields can make wonders :-)

I am seting up directory with this, though have a few questions:

1. I am going to use customized forumdisplay and wish to use different navbar and footer. I tried to change $footer to $footer2 (that I customized), but it seems it can not read this variable. What should I do to make it work?

2. (EDIT: I already figured out ;) )

3. It is great to use something like this $thread[gars8] in forumdisplay template. However I can only use value from this variable, but how to use title of this? In my case it is checkbox. Value of the checkbox is too long to be displayed in forumdisplay tmp, so some acronym would be far better. Is there a solution to this or some IF $thread[gars8] VALUE=XY THEN PRINT X workaround? I am not a coder .-)

4. Again checkbox custom fields. How do I line up the value of 5 checkbox in module so that each checkbox value occupy one row?
Example:
curent output in modulebox:
coder, php
developer, css designer, photoshop
designer, corel designer

Desired output in modulebox:
coder
php developer
css designer
photoshop designer
corel desginer

... so what it should do - it will break line after each item and not seprate them with commas

The Geek
11-17-2006, 08:41 AM
1- Im not too sure about this. I would assume that replacing $footer with the HTML you want would suffice.

2- Excellent :)

3- <if condition="$thread[gars8]=='x'">Hi mom!</if>

4- Some custom fields (i.e. multi checkboxes) do not display in an easy to use fashion (like your example). I suppose I can look at adding a hook so you can format them how you would like. Shouldnt be too hard.

Metal
12-01-2006, 08:39 PM
Tks, it really helps!