Pārlūkot izejas kodu

Adding docs for creating a pager

Stephen Ficklin 6 gadi atpakaļ
vecāks
revīzija
19be2dbd98

+ 1 - 0
docs/dev_guide/custom_field.rst

@@ -43,4 +43,5 @@ The rest of this section will walk you through these steps.
    custom_field/select_vocab_terms
    custom_field/manual_field_creation
    custom_field/custom_widget
+   custom_field/custom_formatter
    custom_field/tripal_field_generator

+ 2 - 2
docs/dev_guide/custom_field/custom_widget.rst

@@ -1,10 +1,10 @@
 Creating a Custom Widget
 ========================
 
-In Drupal/Tripal terminology, **widget** refers to the form elements for a specific Tripal Field on the "Edit" form of a piece of Tripal Content. For example, the ``obi__organism`` widget creates the "Organism" drop-down on the edit form of a specific gene. All fields come with a default widget; however, you can create a custom widget if the default one doesn't meet your needs.
+In Drupal/Tripal terminology, **widget** refers to the form elements for a specific Tripal Field on the "Edit" form of a piece of Tripal Content. For example, the ``obi__organism`` field widget creates the "Organism" drop-down on the edit form of a gene. All fields come with a default widget; however, you can create a custom widget if the default one doesn't meet your needs.
 
 .. note::
-  This guide is going to assume you already have your widget file created. For more information, see :doc:`manual_field_creation` or, :doc:`tripal_field_generator`.
+  This guide assumes you already have your widget class file created. For more information, see :doc:`manual_field_creation` or, :doc:`tripal_field_generator`.
 
 .. note::
 	If you are only creating a widget and not the whole field, you still need to follow the expected directory structure. For example, if your widget is going to be named ``obi__organism_fancy`` then your file would be ``[your_module]/includes/TripalField/obi__organism_fancy/obi__organism_fancy_widget.inc``.

+ 1 - 19
docs/dev_guide/custom_field/manual_field_creation.rst

@@ -1,17 +1,13 @@
 Manual Field Creation
 ======================
-
 To show how a TripalField works we will break down a class implementation section by section.  Here we will use the **obi__organism** field that comes with Tripal and which extends the ChadoField class.  The ChadoField class is almost identical to the TripalField class except that it provides a few extra settings for working with Chado tables.   To create your own class you need to create a new class that implements the necessary functions.
 
 .. note::
   Creation of your first field may not seem easy!  The following document is a lot to think about and consider. Therefore, when you write your first field, don't try to do everything at once. Take it one piece at a time.  The variables and functions described here are in order with the most critical components described first.  Take it at an even pace.
 
 
-
 Directory Structure for Fields
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-
 Before we create our class we must first create a proper directory structure.  Tripal expects that all new Tripal field classes are located inside of a custom module in the following directory structure:
 
 .. code-block:: bash
@@ -31,7 +27,6 @@ In the directories above the token [your_module] can be substituted with the nam
 
 Anatomy of the ChadoField Class
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
 The following describes a ChadoField class from top to bottom. The code for the obi__organism field is shown in order that it appears in the class with descriptions provided for the meaning of each piece of code.  To write your own class, duplicate the variables and function and customize accordingly.  First, let's look at the definition of the class.  The following line defines the class and indicates that it extends the ChadoField class:
 
 .. code-block:: php
@@ -133,8 +128,6 @@ Finally, the last item in our Class variables is the **download_formatters**.  T
 
 .. .. code-block::
 
-  
-
   // Indicates the download formats for this field.  The list must be the
   // name of a child class of the TripalFieldDownloader.
   public static $download_formatters = array(
@@ -154,7 +147,6 @@ To get started, the load() function receives a single argument. The entity objec
 
 .. code-block:: php
 
-
   public function load($entity) {
 
 
@@ -162,7 +154,6 @@ Because this is a ChadoField and the TripalChado module supports this field and
 
 .. code-block:: php
 
-
     $record = $entity->chado_record;
 
 Having the record helps tremendously.  Our **obi__organism** field is meant to be attached to genomic feature content types (e.g. genes, mRNA, etc.), germplasm, etc.  Therefore, the entity will be a record of one of those types. In the case of a genomic feature, these come from the **feature** table of Chado.  In the case of a germplam, these records come from the **stock** table of Chado.  Both of these records have an **organism_id** field which is a foreign key to the organism table where we find out details about the organism.
@@ -171,7 +162,6 @@ Before we set the values for our field, we need a little bit more information.
 
 .. code-block:: php
 
-
     $settings = $this->instance['settings'];
     $field_table = $this->instance['settings']['chado_table'];
     $field_column = $this->instance['settings']['chado_column'];
@@ -180,7 +170,6 @@ Next, we want to get this field name and its type.  We obviously know our field
 
 .. code-block:: php
 
-
     $field_name = $this->field['field_name'];
     $field_type = $this->field['type'];
 
@@ -189,7 +178,6 @@ Now, let's plan how we want our values to appear in our field.  The organism rec
 
 .. code-block:: php
 
-
     // Get the terms for each of the keys for the 'values' property.
     $label_term = 'rdfs:label';
     $genus_term = tripal_get_chado_semweb_term('organism', 'genus');
@@ -204,7 +192,6 @@ Next, let's initialize our field's value to be empty.  When setting a field valu
 
 .. code-block:: php
 
-
     // Set some defaults for the empty record.
     $entity->{$field_name}['und'][0] = array(
       'value' => array(),
@@ -217,7 +204,6 @@ Now that we've got some preliminary values and we've initialized our value array
 
 .. code-block:: php
 
-
     if ($record) {
 
 
@@ -225,7 +211,6 @@ Now if we do have a record we need to get the value  The first step is to actual
 
 .. code-block:: php
 
-
       if ($field_table == 'biomaterial') {
         $organism = $record->taxon_id;
       }
@@ -235,9 +220,7 @@ Now if we do have a record we need to get the value  The first step is to actual
 
 We can easily get all of the values we need from this organism object.   We can now access the values for this organism using the Chado organism table column names (e.g. $organism->genus, $organism->species).
 
-.. code-block:: php
-
-  
+.. code-block:: php 
 
       $label = tripal_replace_chado_tokens($string, $organism);
       $entity->{$field_name}['und'][0]['value'] = array(
@@ -260,7 +243,6 @@ Okay, so, we have our values set. However, remember,  our fields must support tw
 
 .. code-block:: php
 
-
     // Set the linker field appropriately.
     if ($field_table == 'biomaterial') {
       $linker_field = 'chado-biomaterial__taxon_id';