You are here

README.txt in Office Hours 8

Same filename and directory in other branches
  1. 7 README.txt
Office Hours creates a Field, that you can add to any entity (like a location,
a restaurant or a user) to represent "office hours" or "opening hours".

== GENERAL FEATURES ==
The widget provides:
- default weekly office hours (multi-value, per field instance).
- using 1, 2 or even more 'time slots' per day (thanks to jonhattan).
- 'allowed hours' restrictions;
- input validation;
- use of either a 24 or 12 hour clock;

The formatter provides o.a.:
- a 'Current status' indicator ('open now'/'closed now');
- options to show all/none/open/current days;
- options to group days (E.g., "Mon-Fri 12:00-22:00");
- customizable element separators to display the 'office hours' any way you want. (See below for details.)

You can configure the formatter as follows:
- Add the field to an entity/node;
- Select the 'Office hours' formatter;
- Set the formatter details at /admin/structure/types/manage/NODE_TYPE/display/VIEW_MODE;
or
- Add the field to a view;
- Select the 'Office hours' formatter;
- Check the formatter settings of the field;


== FORMATTING THE HOURS ==
Using the customizable separators in the formatter settings, you can format the hours any way you want. 
- The formatter is default set up to show a nice table.
- To export the data to a Google Places bulk upload file, you can create a view,
  and set the formatter to generate the following data (for a shop that opens from Monday to Friday): 
    2:10:00:18:00,3:10:00:18:00,4:10:00:18:00,5:10:00:18:00,6:10:00:18:00,7:12:00:20:00


== USING VIEWS - FIELDS ==
Add the Field to any Views display, as you are used to do.
- To show only 1 day per row in a Views display: 
  - add the field to your View,
  - open the MULTIPLE FIELD SETTINGS section,
  - UNcheck the option 'Display all values in the same row',
  - make also sure you display 'all' values. (only valid if you have upgraded from 1.1 version.)

== USING VIEWS - FILTER CRITERIA ==
Only default (out-of-the-box) Views functionality is provided.
- To show only the entities that have a office hours: 
  - add the filter criterion "Content: Office hours (field_office_hours:day)" to your View,
  - set the filter option 'Operator' to 'is not empty',
- To show only the entities that have office hours for e.g., Friday: 
  - add the filter criterion "Content: Office hours (field_office_hours:day)" to your View,
  - set the filter option 'Operator' to 'is equal to',
  - set the filter option 'Value' to '5', or leave 'Value' empty and set 'Expose operator' to YES.
- To show only the entities that are open NOW: 
  This is not possible, yet. 


== USING VIEWS - SORT CRITERIA ==
Only default (out-of-the-box) Views functionality is provided.
- To sort the times per day, add the 'day' sort criterion. 


== USING VIEWS - CREATE A BLOCK PER NODE/ENTITY ==
Suppose you want to show the Office hours on a node page, but NOT on the page itself, 
but rather in a separate block, follow these instructions:
(If you use non-Node Content types/Entities, you'll need to adapt some settings.)
1. First, create a new View for 'Content', and add a Block display;
 - Under FORMAT, set to an Unformatted list of Fields;
 - Under FIELDS, add the office_hours field and other fields you like;
 - Under FILTER CRITERIA, add the relevant Content type(s);
 - Under PAGER, show all items;
 - Now open the ADVANCED section;
 - Under CONTEXTUAL FILTERS, add 'Content: Nid';
 -- Set 'Provide default value' to 'Content ID from URL';
 -- Set 'Specify validation criteria' to the same Content type(s) as under FILTERS;
 -- Set 'Filter value format' according to your wishes;
 -- Set 'Action to take if filter value does not validate' to 'Hide View';
 - Tweak the other settings as you like.

2. Now, configure your new Block under /admin/structure/block/manage/ : 
 - Set the Block title, and the Region settings;
 - Under PAGES, set 'Show block on specific pages' to 'Only the listed pages' and 'node/*';
   You might want to add more pages, if you use other non-node entity types.
 - Tweak the other settings as you like.
 You'll need to tune the block for the following cases: 
 - A user accesses the node page, but 'Access denied';
 - A node is unpublised;

Now, test your node page. You'll see the Office hours in the page AND in the block. That's once too many.

3. So, modify the 'View mode' of your Content type under /admin/structure/types/manage/<MY_CONTENT_TYPE>/display
 - Select MANAGE DISPLAY;
 - Select the View mode. (Perhaps you need to create an extra view mode for other purposes.)
 - Select the Office_hours, and set the Format to 'Hidden';
 - Save the data, end enjoy the result!

== D7: IMPORTING WITH FEEDS MODULE ==
To import data with the Feeds module, the following columns can be used:
- day;
- hours/morehours from;
- hours/morehours to;
- hours/morehours from-to.

The day should be stated in full English name, or a day number where sunday = 0, monday=1, etc.
The hours can be formatted as hh:mm or hh.mm

I suppose Feeds Tamper can help to format the times and/or day to the proper format.

Here is an example file:
nid;weekday;Hours_1;Hours_2
2345;monday;11:00 - 18:01;
2345;tuesday;10:00 - 12:00;13:15-17.45
2383;monday;11:00 - 18:01;
2383;tuesday;10:00 - 12:00;13:15-17.45


== D8: Migrating from external source ==
Create a migrate process plugin that returns an array like this:

  Array
  (
      [1] => Array
          (
              [day] => 1
              [starthours] => 1600
              [endhours] => 2200
          )

      [2] => Array
          (
              [day] => 2
              [starthours] => 1600
              [endhours] => 2200
          )

      [3] => Array
          (
              [day] => 3
              [starthours] => 1600
              [endhours] => 2200
          )

      [4] => Array
          (
              [day] => 4
              [starthours] => 1300
              [endhours] => 2200
          )

      [5] => Array
          (
              [day] => 5
              [starthours] => 1300
              [endhours] => 2300
          )

      [6] => Array
          (
              [day] => 6
              [starthours] => 1300
              [endhours] => 2300
          )

      [7] => Array
          (
              [day] => 0
              [starthours] => 1300
              [endhours] => 2100
          )
  )

Note that the array key doesn't matter, but that day 0 = Sunday. 
If you have multiple slots per day, add a new entry with the same the [day] value.

In your migration yml, you can do something like this: 

  field_opening_hours:
    -
      plugin: opening_hours
      source: opening_hours
    -
      plugin: office_hours_field_plugin

where the office_hours_field_plugin is supplied by this office_hours module.

File

README.txt
View source
  1. Office Hours creates a Field, that you can add to any entity (like a location,
  2. a restaurant or a user) to represent "office hours" or "opening hours".
  3. == GENERAL FEATURES ==
  4. The widget provides:
  5. - default weekly office hours (multi-value, per field instance).
  6. - using 1, 2 or even more 'time slots' per day (thanks to jonhattan).
  7. - 'allowed hours' restrictions;
  8. - input validation;
  9. - use of either a 24 or 12 hour clock;
  10. The formatter provides o.a.:
  11. - a 'Current status' indicator ('open now'/'closed now');
  12. - options to show all/none/open/current days;
  13. - options to group days (E.g., "Mon-Fri 12:00-22:00");
  14. - customizable element separators to display the 'office hours' any way you want. (See below for details.)
  15. You can configure the formatter as follows:
  16. - Add the field to an entity/node;
  17. - Select the 'Office hours' formatter;
  18. - Set the formatter details at /admin/structure/types/manage/NODE_TYPE/display/VIEW_MODE;
  19. or
  20. - Add the field to a view;
  21. - Select the 'Office hours' formatter;
  22. - Check the formatter settings of the field;
  23. == FORMATTING THE HOURS ==
  24. Using the customizable separators in the formatter settings, you can format the hours any way you want.
  25. - The formatter is default set up to show a nice table.
  26. - To export the data to a Google Places bulk upload file, you can create a view,
  27. and set the formatter to generate the following data (for a shop that opens from Monday to Friday):
  28. 2:10:00:18:00,3:10:00:18:00,4:10:00:18:00,5:10:00:18:00,6:10:00:18:00,7:12:00:20:00
  29. == USING VIEWS - FIELDS ==
  30. Add the Field to any Views display, as you are used to do.
  31. - To show only 1 day per row in a Views display:
  32. - add the field to your View,
  33. - open the MULTIPLE FIELD SETTINGS section,
  34. - UNcheck the option 'Display all values in the same row',
  35. - make also sure you display 'all' values. (only valid if you have upgraded from 1.1 version.)
  36. == USING VIEWS - FILTER CRITERIA ==
  37. Only default (out-of-the-box) Views functionality is provided.
  38. - To show only the entities that have a office hours:
  39. - add the filter criterion "Content: Office hours (field_office_hours:day)" to your View,
  40. - set the filter option 'Operator' to 'is not empty',
  41. - To show only the entities that have office hours for e.g., Friday:
  42. - add the filter criterion "Content: Office hours (field_office_hours:day)" to your View,
  43. - set the filter option 'Operator' to 'is equal to',
  44. - set the filter option 'Value' to '5', or leave 'Value' empty and set 'Expose operator' to YES.
  45. - To show only the entities that are open NOW:
  46. This is not possible, yet.
  47. == USING VIEWS - SORT CRITERIA ==
  48. Only default (out-of-the-box) Views functionality is provided.
  49. - To sort the times per day, add the 'day' sort criterion.
  50. == USING VIEWS - CREATE A BLOCK PER NODE/ENTITY ==
  51. Suppose you want to show the Office hours on a node page, but NOT on the page itself,
  52. but rather in a separate block, follow these instructions:
  53. (If you use non-Node Content types/Entities, you'll need to adapt some settings.)
  54. 1. First, create a new View for 'Content', and add a Block display;
  55. - Under FORMAT, set to an Unformatted list of Fields;
  56. - Under FIELDS, add the office_hours field and other fields you like;
  57. - Under FILTER CRITERIA, add the relevant Content type(s);
  58. - Under PAGER, show all items;
  59. - Now open the ADVANCED section;
  60. - Under CONTEXTUAL FILTERS, add 'Content: Nid';
  61. -- Set 'Provide default value' to 'Content ID from URL';
  62. -- Set 'Specify validation criteria' to the same Content type(s) as under FILTERS;
  63. -- Set 'Filter value format' according to your wishes;
  64. -- Set 'Action to take if filter value does not validate' to 'Hide View';
  65. - Tweak the other settings as you like.
  66. 2. Now, configure your new Block under /admin/structure/block/manage/ :
  67. - Set the Block title, and the Region settings;
  68. - Under PAGES, set 'Show block on specific pages' to 'Only the listed pages' and 'node/*';
  69. You might want to add more pages, if you use other non-node entity types.
  70. - Tweak the other settings as you like.
  71. You'll need to tune the block for the following cases:
  72. - A user accesses the node page, but 'Access denied';
  73. - A node is unpublised;
  74. Now, test your node page. You'll see the Office hours in the page AND in the block. That's once too many.
  75. 3. So, modify the 'View mode' of your Content type under /admin/structure/types/manage//display
  76. - Select MANAGE DISPLAY;
  77. - Select the View mode. (Perhaps you need to create an extra view mode for other purposes.)
  78. - Select the Office_hours, and set the Format to 'Hidden';
  79. - Save the data, end enjoy the result!
  80. == D7: IMPORTING WITH FEEDS MODULE ==
  81. To import data with the Feeds module, the following columns can be used:
  82. - day;
  83. - hours/morehours from;
  84. - hours/morehours to;
  85. - hours/morehours from-to.
  86. The day should be stated in full English name, or a day number where sunday = 0, monday=1, etc.
  87. The hours can be formatted as hh:mm or hh.mm
  88. I suppose Feeds Tamper can help to format the times and/or day to the proper format.
  89. Here is an example file:
  90. nid;weekday;Hours_1;Hours_2
  91. 2345;monday;11:00 - 18:01;
  92. 2345;tuesday;10:00 - 12:00;13:15-17.45
  93. 2383;monday;11:00 - 18:01;
  94. 2383;tuesday;10:00 - 12:00;13:15-17.45
  95. == D8: Migrating from external source ==
  96. Create a migrate process plugin that returns an array like this:
  97. Array
  98. (
  99. [1] => Array
  100. (
  101. [day] => 1
  102. [starthours] => 1600
  103. [endhours] => 2200
  104. )
  105. [2] => Array
  106. (
  107. [day] => 2
  108. [starthours] => 1600
  109. [endhours] => 2200
  110. )
  111. [3] => Array
  112. (
  113. [day] => 3
  114. [starthours] => 1600
  115. [endhours] => 2200
  116. )
  117. [4] => Array
  118. (
  119. [day] => 4
  120. [starthours] => 1300
  121. [endhours] => 2200
  122. )
  123. [5] => Array
  124. (
  125. [day] => 5
  126. [starthours] => 1300
  127. [endhours] => 2300
  128. )
  129. [6] => Array
  130. (
  131. [day] => 6
  132. [starthours] => 1300
  133. [endhours] => 2300
  134. )
  135. [7] => Array
  136. (
  137. [day] => 0
  138. [starthours] => 1300
  139. [endhours] => 2100
  140. )
  141. )
  142. Note that the array key doesn't matter, but that day 0 = Sunday.
  143. If you have multiple slots per day, add a new entry with the same the [day] value.
  144. In your migration yml, you can do something like this:
  145. field_opening_hours:
  146. -
  147. plugin: opening_hours
  148. source: opening_hours
  149. -
  150. plugin: office_hours_field_plugin
  151. where the office_hours_field_plugin is supplied by this office_hours module.