You are here

README.txt in Context Field 7

I. Installation
--------------------------------------
Install and enable the following modules, preferably using Drush:
* Context (7.x-3.0-beta2 and up) http://drupal.org/project/context
* Context UI (included as a sub-module in Context)
* Context Field (7.x-1.0-beta1 and up) http://drupal.org/project/context_field

* Boxes (7.x-1.0-beta5 and up) http://drupal.org/project/boxes
* Views (7.x-3.0-rc1 and up) http://drupal.org/project/views
* Ctools (7.x-1.0-rc1 and up) http://drupal.org/project/ctools
* Entity Autocomplete (7.x-1.0-beta1 and up) http://drupal.org/project/entity_autocomplete

* Views Boxes (7.x-1.0-beta4 and up) http://drupal.org/project/views_boxes
* Views Arguments Extras (7.x-1.0-beta1 and up) http://drupal.org/project/views_arguments_extras


II. Using Context Field
--------------------------------------
In this tutorial, we're going to enhance the basic page content type with
Context Field so that each new page will have its own automatically
created context.

* Go to /admin/structure/types and click 'manage fields' on Basic page.

* Add a new field of the Context type, and set the options dropdown to 
  Auto Create, then save.

* On the follow-up page, click 'Save field settings'.

* You'll then see a number of ways to configure how this specific field
  behaves. The Default Context is the one that ships with the module, 
  and we will set the use to 'Clone default context on Entity Creation', 
  meaning we'll a new copy of that one for each page we create.
  Alternatively, we can pick 'Always use Default Context' to essentially
  reference one specific context for all page nodes. Once you've decided
  on this, save your settings.

* Create and save a test page node.

* You'll notice the 'Configure layout' link when you view the node.
  If not, make sure that your role has the 'Use Context Field Editor'
  permission. Click on that link.

* You are now in context editing mode, with the editor widget to the
  right of your screen. You can now use the dropdown to filter on the
  category of block-type items that you can then drag and drop into
  the region of your choice. If you've used Context UI before, this
  should be familiar to you. For testing purposes, Select User in
  the dropdown then drag and drop "Who's Online" into the Featured
  region. The block will then render its contents.

* Any changes made to the currently selected context (viewable in
  the Context Field editor) will need to get saved by clicking 'Done'
  and then 'Save changes'. Should your current page have multiple
  contexts, you can edit a specific one by clicking the corresponding
  'Edit' button next to it in the editor.

* You can minimize the Context Editor by clicking its grey title bar,
  and you can get out of the context editing mode by clicking the 'X'.


III. Using Views Boxes with Context Field
--------------------------------------
Now let's make this interesting and use the Context Editor with
some Views Boxes.

III.A. Basic use:
--------------------------------------
* Enter a couple of article nodes (just set the titles for now).

* Make sure you have Views UI enabled and then create a new view
  (called list_articles) with a block display that returns the titles
  of your published articles.

* Go back to your test page and reclick 'Configure Layout'.

* Select Boxes in the editor's dropdown, and then drag and drop
  'Add custom view box' into a region.

* You'll be prompted to set the box's description (which is used
  for admin UI purposes) and its title (which is actually rendered
  and shown to end users). Set the title to <none> and the description
  to 'Views Box - Articles' and then click Continue.

* The 'View' dropdown shown then allows you to pick the block display
  you want this box instance to use. For now, we just have list_articles
  which doesn't have any exposed or contextual filters, so we can go
  ahead and save our settings.

* You'll now see your list of articles.

III.B. Exposed and contextual filters:
--------------------------------------
Views Boxes ships with some filters that are particularly useful for 
allowing extra levels of control over your view while still storing
the configuration data in the box itself. We're going to cover the ability
to curate this list_articles so that we can manually sort the article nodes
through the box. For this, we're going to install the Views Arguments Extras
module as it provides some filters that we'll need.

* Go edit the list_articles view.

* Add a contextual filter and select 'Content: Nid'. Before you save it,
  scroll down and open up the 'More' options.

* The administrative title can be used for two purposes: displaying what it
  is that we'll be selecting (Article nodes) to the admin when using the box,
  and to limit the autocomplete fields we'll have to specific entities and
  bundles. By default the autocomplete field will display all nodes, but if
  we want to restrict it to articles, we'd enter: 
  Article nodes [node] {bundles:article} here

* Check the 'Allow multiple values' option and save your changes.

* Add a sort criteria and select 'Arguments: Multi-item Argument Order'.
  This insures that we're actually sorting using the nodes we'll be selecting
  through the contextual filter in the box. Make sure that this sort criteria
  comes before the existing 'Content: Post date' and it's set to
  'sort descending'. Save your changes to the view and go back to your page
  node with the list_articles view block.

* Edit the box by clicking the gear icon that appears when you hover over it
  and then selecting 'Edit Box'. Notice that you don't necessarily need to be
  in Context Editor mode to edit existing boxes.

* You'll notice that you now get 'Article Nodes' under settings for the box,
  which allows you to pick article nodes using the autocomplete fields and to
  order them as you'd like. Once you're done with this, save the changes and
  you'll get your manually reordered list.

* You can reuse the same box instance or another page if you want to keep the
  same ordered list, but you can also create a new custom view box that reuses
  the same view display but with a different selection of nodes. This allows
  for a pretty powerful way to make views configurable through the box interface
  while still keeping the benefits of reusing the same displays (templates
  for examples). Other filters can be exposed too and used through the box
  interface, and having a view box filter on a specific taxonomy term can be
  achieved in a similar manner.

Documentation written by tirdadc - http://drupal.org/user/383630

File

README.txt
View source
  1. I. Installation
  2. --------------------------------------
  3. Install and enable the following modules, preferably using Drush:
  4. * Context (7.x-3.0-beta2 and up) http://drupal.org/project/context
  5. * Context UI (included as a sub-module in Context)
  6. * Context Field (7.x-1.0-beta1 and up) http://drupal.org/project/context_field
  7. * Boxes (7.x-1.0-beta5 and up) http://drupal.org/project/boxes
  8. * Views (7.x-3.0-rc1 and up) http://drupal.org/project/views
  9. * Ctools (7.x-1.0-rc1 and up) http://drupal.org/project/ctools
  10. * Entity Autocomplete (7.x-1.0-beta1 and up) http://drupal.org/project/entity_autocomplete
  11. * Views Boxes (7.x-1.0-beta4 and up) http://drupal.org/project/views_boxes
  12. * Views Arguments Extras (7.x-1.0-beta1 and up) http://drupal.org/project/views_arguments_extras
  13. II. Using Context Field
  14. --------------------------------------
  15. In this tutorial, we're going to enhance the basic page content type with
  16. Context Field so that each new page will have its own automatically
  17. created context.
  18. * Go to /admin/structure/types and click 'manage fields' on Basic page.
  19. * Add a new field of the Context type, and set the options dropdown to
  20. Auto Create, then save.
  21. * On the follow-up page, click 'Save field settings'.
  22. * You'll then see a number of ways to configure how this specific field
  23. behaves. The Default Context is the one that ships with the module,
  24. and we will set the use to 'Clone default context on Entity Creation',
  25. meaning we'll a new copy of that one for each page we create.
  26. Alternatively, we can pick 'Always use Default Context' to essentially
  27. reference one specific context for all page nodes. Once you've decided
  28. on this, save your settings.
  29. * Create and save a test page node.
  30. * You'll notice the 'Configure layout' link when you view the node.
  31. If not, make sure that your role has the 'Use Context Field Editor'
  32. permission. Click on that link.
  33. * You are now in context editing mode, with the editor widget to the
  34. right of your screen. You can now use the dropdown to filter on the
  35. category of block-type items that you can then drag and drop into
  36. the region of your choice. If you've used Context UI before, this
  37. should be familiar to you. For testing purposes, Select User in
  38. the dropdown then drag and drop "Who's Online" into the Featured
  39. region. The block will then render its contents.
  40. * Any changes made to the currently selected context (viewable in
  41. the Context Field editor) will need to get saved by clicking 'Done'
  42. and then 'Save changes'. Should your current page have multiple
  43. contexts, you can edit a specific one by clicking the corresponding
  44. 'Edit' button next to it in the editor.
  45. * You can minimize the Context Editor by clicking its grey title bar,
  46. and you can get out of the context editing mode by clicking the 'X'.
  47. III. Using Views Boxes with Context Field
  48. --------------------------------------
  49. Now let's make this interesting and use the Context Editor with
  50. some Views Boxes.
  51. III.A. Basic use:
  52. --------------------------------------
  53. * Enter a couple of article nodes (just set the titles for now).
  54. * Make sure you have Views UI enabled and then create a new view
  55. (called list_articles) with a block display that returns the titles
  56. of your published articles.
  57. * Go back to your test page and reclick 'Configure Layout'.
  58. * Select Boxes in the editor's dropdown, and then drag and drop
  59. 'Add custom view box' into a region.
  60. * You'll be prompted to set the box's description (which is used
  61. for admin UI purposes) and its title (which is actually rendered
  62. and shown to end users). Set the title to and the description
  63. to 'Views Box - Articles' and then click Continue.
  64. * The 'View' dropdown shown then allows you to pick the block display
  65. you want this box instance to use. For now, we just have list_articles
  66. which doesn't have any exposed or contextual filters, so we can go
  67. ahead and save our settings.
  68. * You'll now see your list of articles.
  69. III.B. Exposed and contextual filters:
  70. --------------------------------------
  71. Views Boxes ships with some filters that are particularly useful for
  72. allowing extra levels of control over your view while still storing
  73. the configuration data in the box itself. We're going to cover the ability
  74. to curate this list_articles so that we can manually sort the article nodes
  75. through the box. For this, we're going to install the Views Arguments Extras
  76. module as it provides some filters that we'll need.
  77. * Go edit the list_articles view.
  78. * Add a contextual filter and select 'Content: Nid'. Before you save it,
  79. scroll down and open up the 'More' options.
  80. * The administrative title can be used for two purposes: displaying what it
  81. is that we'll be selecting (Article nodes) to the admin when using the box,
  82. and to limit the autocomplete fields we'll have to specific entities and
  83. bundles. By default the autocomplete field will display all nodes, but if
  84. we want to restrict it to articles, we'd enter:
  85. Article nodes [node] {bundles:article} here
  86. * Check the 'Allow multiple values' option and save your changes.
  87. * Add a sort criteria and select 'Arguments: Multi-item Argument Order'.
  88. This insures that we're actually sorting using the nodes we'll be selecting
  89. through the contextual filter in the box. Make sure that this sort criteria
  90. comes before the existing 'Content: Post date' and it's set to
  91. 'sort descending'. Save your changes to the view and go back to your page
  92. node with the list_articles view block.
  93. * Edit the box by clicking the gear icon that appears when you hover over it
  94. and then selecting 'Edit Box'. Notice that you don't necessarily need to be
  95. in Context Editor mode to edit existing boxes.
  96. * You'll notice that you now get 'Article Nodes' under settings for the box,
  97. which allows you to pick article nodes using the autocomplete fields and to
  98. order them as you'd like. Once you're done with this, save the changes and
  99. you'll get your manually reordered list.
  100. * You can reuse the same box instance or another page if you want to keep the
  101. same ordered list, but you can also create a new custom view box that reuses
  102. the same view display but with a different selection of nodes. This allows
  103. for a pretty powerful way to make views configurable through the box interface
  104. while still keeping the benefits of reusing the same displays (templates
  105. for examples). Other filters can be exposed too and used through the box
  106. interface, and having a view box filter on a specific taxonomy term can be
  107. achieved in a similar manner.
  108. Documentation written by tirdadc - http://drupal.org/user/383630