mardi 3 décembre 2013

gRSShopper Setup (2)

Making Optlists
[Note: Ce billet en suite au premier billet d'installation de gRSShopper. Nous attendions de le traduire avant de le publier. Pour le moment, le voici en format original anglais.]
Preparing for the MOOC-REL course I filled in a full set of optlists.

An 'optlist' is the information required to create a dropdown list. These lists create predefine options in the forms people use to create new posts, events, pages, etc.

So, for example, a 'post' might have a field called 'status'. Normally it would just be a plain text field, and you'd type in the name of the type. But it's easier just to select a value from a predefined list. The 'optlist' defines this list.

Administrators can crate optlists by clicking on [New] Optlist in the admin screen(the direct link is http://yoururl/cgi-bin/admin.cgi?db=optlist&action=edit ) and providing the following information:

Table: the name of the table
Field: the name of the field

Data: this is the list of options. It's a structured list: optiontitle,optionvalue;optiontitle2,optionvalue2
Just type out the just. (You can experiment with this to get it right).
For example: Approved,A;On Hold,O;Retired,R

Adding Fields to Tables
Setting up the optlists, I noticed some fields were not updating properly - I would enter the value and it would just disappear when I updated the form. This happens when the field is not defined in the table.

I can add a field to any table using the Database functions. Click on the 'Database' tab in the admin screen and look for 'Manage Database'. Select the table to look at, then select 'Show Columns' from the drop down. This will tell me the names of all the fields in the database.

To add the new field, type the name of the field in the space and select 'Add Column' from the dropdown.  

Note all table column field names begin with the name of the table. So, for example, to add a 'title' field to the 'event' table, the name of the field must be 'event_field'. This way, every single field in the database has a unique name.

Note to change the list of fields that will be displayed for any given table in admin.cgi, go to the edit_record() function (it's the content beginning my $showcols = ...). This is hard-coded for now but will one day be part of the general admin screen. You will need to do this if you add a field that wasn't previously defined.

I noticed things like the delete buttons were not working. Many of the basic functions (including delete alerts and login status updates are handled by the grsshopper.js Javascript library. The templates were still pointing to the older downes.js I was using previously. So I changed the script include to read src=""></script>

While I was looking at this I checked the grsshopper.js script. It is supposed to be configured by the installer but that does not always work properly. That was the case here. First, it was an older script. Second, the site information wasn't correctly added.

You can always get a correct up-to-date grsshopper sscript from my website:
I downloaded this (you would replace with your own base URL).

Then I reset the values at the top of the script (these are needed to make the 'login' script at the top of the page work properly):
var base_url = "";
var cgi_url = "";
var title_cookie = "123_45_67_89_person_title";

Aucun commentaire:

Publier un commentaire