gRSShopper Setup (2)

Making Optlists

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.

grsshopper.js

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="http://123.45.67.89/assets/js/grsshopper.js"></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:
http://www.downes.ca/assets/js/grsshopper.js
I downloaded this (you would replace 123.45.67.89 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 = "http://123.45.67.89/";
var cgi_url = "http://123.45.67.89/cgi-bin/";
var title_cookie = "
123_45_67_89_person_title";




Comments

Popular Posts