Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
WCMS
uw_ct_event
Commits
a3351147
Commit
a3351147
authored
Jun 18, 2021
by
Chris Shantz
Browse files
Merge branch '1.0.x' into prod/1.0.x
parents
7e6b9dfb
0d707bd3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
181 deletions
+100
-181
config/install/core.entity_view_display.node.uw_ct_event.default.yml
...all/core.entity_view_display.node.uw_ct_event.default.yml
+0
-134
config/install/views.view.uw_view_events.yml
config/install/views.view.uw_view_events.yml
+8
-9
uw_ct_event.install
uw_ct_event.install
+83
-7
uw_ct_event.module
uw_ct_event.module
+9
-31
No files found.
config/install/core.entity_view_display.node.uw_ct_event.default.yml
View file @
a3351147
...
...
@@ -2,7 +2,6 @@ langcode: en
status
:
true
dependencies
:
config
:
-
core.base_field_override.node.uw_ct_event.title
-
field.field.node.uw_ct_event.field_uw_audience
-
field.field.node.uw_ct_event.field_uw_event_cost
-
field.field.node.uw_ct_event.field_uw_event_date
...
...
@@ -36,95 +35,6 @@ third_party_settings:
allow_custom
:
true
enabled
:
true
sections
:
-
layout_id
:
uw_1_column
layout_settings
:
label
:
'
'
layout_builder_styles_style
:
uw_lbs_contained_width
layout_builder_id
:
'
'
components
:
1ba4b322-8a7a-477d-92d3-df2123766273
:
uuid
:
1ba4b322-8a7a-477d-92d3-df2123766273
region
:
first
configuration
:
id
:
'
field_block:node:uw_ct_event:field_uw_event_date'
label
:
'
Date
and
time'
provider
:
layout_builder
label_display
:
'
0'
formatter
:
label
:
hidden
type
:
smartdate_default
settings
:
timezone_override
:
'
'
format
:
default
force_chronological
:
false
third_party_settings
:
fences
:
fences_field_tag
:
none
fences_field_classes
:
'
'
fences_field_item_tag
:
none
fences_field_item_classes
:
'
'
fences_label_tag
:
none
fences_label_classes
:
'
'
context_mapping
:
entity
:
layout_builder.entity
view_mode
:
view_mode
additional
:
layout_builder_id
:
'
'
weight
:
0
edcdcadd-ffbb-44e1-a1d7-ae5474d0e1b8
:
uuid
:
edcdcadd-ffbb-44e1-a1d7-ae5474d0e1b8
region
:
first
configuration
:
id
:
'
field_block:node:uw_ct_event:title'
label
:
Title
provider
:
layout_builder
label_display
:
'
0'
formatter
:
label
:
hidden
type
:
string
settings
:
link_to_entity
:
false
third_party_settings
:
fences
:
fences_field_tag
:
none
fences_field_classes
:
'
'
fences_field_item_tag
:
none
fences_field_item_classes
:
'
'
fences_label_tag
:
none
fences_label_classes
:
'
'
context_mapping
:
entity
:
layout_builder.entity
view_mode
:
view_mode
additional
:
layout_builder_id
:
'
'
weight
:
1
91e3aae6-f8ef-45a3-9a8a-dbff5d0a14b8
:
uuid
:
91e3aae6-f8ef-45a3-9a8a-dbff5d0a14b8
region
:
first
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_event:field_uw_audience'
formatter
:
label
:
above
settings
:
link
:
true
third_party_settings
:
{
}
type
:
entity_reference_label
additional
:
{
}
weight
:
2
third_party_settings
:
layout_builder_lock
:
lock
:
1
:
1
2
:
2
3
:
3
4
:
4
5
:
5
6
:
6
8
:
8
-
layout_id
:
uw_1_column
layout_settings
:
...
...
@@ -366,50 +276,6 @@ third_party_settings:
layout_builder_id
:
'
'
weight
:
12
third_party_settings
:
{
}
-
layout_id
:
uw_1_column
layout_settings
:
label
:
'
'
layout_builder_styles_style
:
uw_lbs_contained_width
layout_builder_id
:
'
'
components
:
8663f91e-e7eb-49bf-9ad9-eb6e8a7693b6
:
uuid
:
8663f91e-e7eb-49bf-9ad9-eb6e8a7693b6
region
:
first
configuration
:
id
:
'
field_block:node:uw_ct_event:field_uw_event_tags'
label
:
'
Event
tag(s)'
provider
:
layout_builder
label_display
:
'
0'
formatter
:
label
:
hidden
type
:
entity_reference_label
settings
:
link
:
true
third_party_settings
:
fences
:
fences_field_tag
:
none
fences_field_classes
:
'
'
fences_field_item_tag
:
none
fences_field_item_classes
:
'
'
fences_label_tag
:
none
fences_label_classes
:
'
'
context_mapping
:
entity
:
layout_builder.entity
view_mode
:
view_mode
additional
:
layout_builder_id
:
'
'
weight
:
0
third_party_settings
:
layout_builder_lock
:
lock
:
1
:
1
2
:
2
3
:
3
4
:
4
5
:
5
7
:
7
8
:
8
layout_builder_restrictions
:
entity_view_mode_restriction
:
allowed_blocks
:
...
...
config/install/views.view.uw_view_events.yml
View file @
a3351147
...
...
@@ -89,7 +89,7 @@ display:
is_secondary
:
false
select_all_none
:
true
select_all_none_nested
:
false
display_inline
:
0
display_inline
:
false
field_uw_event_tags_target_id
:
plugin_id
:
bef
advanced
:
...
...
@@ -99,7 +99,7 @@ display:
is_secondary
:
false
select_all_none
:
true
select_all_none_nested
:
false
display_inline
:
0
display_inline
:
false
field_uw_audience_target_id
:
plugin_id
:
bef
advanced
:
...
...
@@ -109,7 +109,7 @@ display:
is_secondary
:
false
select_all_none
:
true
select_all_none_nested
:
false
display_inline
:
0
display_inline
:
false
pager
:
type
:
some
options
:
...
...
@@ -656,7 +656,8 @@ display:
display_title
:
'
Event
listing
(block)'
position
:
3
display_options
:
display_extenders
:
{
}
display_extenders
:
metatag_display_extender
:
{
}
display_description
:
'
'
title
:
'
Event
listing'
defaults
:
...
...
@@ -860,12 +861,10 @@ display:
type
:
default
options
:
{
}
row
:
type
:
fields
type
:
'
entity:node'
options
:
default_field_elements
:
true
inline
:
{
}
separator
:
'
'
hide_empty
:
false
relationship
:
none
view_mode
:
teaser
fields
:
title
:
id
:
title
...
...
uw_ct_event.install
View file @
a3351147
...
...
@@ -5,6 +5,9 @@
* Install, update and uninstall for event content type.
*/
use
Drupal\node\Entity\Node
;
use
Drupal\taxonomy\Entity\Term
;
/**
* Implements hook_install().
*/
...
...
@@ -29,13 +32,6 @@ function uw_ct_event_install() {
}
}
/**
* @file
* Contains various helper functions.
*/
use
Drupal\taxonomy\Entity\Term
;
/**
* Helper function to create a taxonomy term programmatically.
*
...
...
@@ -72,3 +68,83 @@ function _uw_ct_event_term_create($term, $vocabulary, array $parent = []) {
// Return the taxonomy term id.
return
$new_term
->
id
();
}
/**
* Removes the first and last section from events.
*/
function
uw_ct_event_update_8101
(
&
$sandbox
)
{
// Get all the nids for blogs.
$nids
=
\
Drupal
::
entityQuery
(
'node'
)
->
condition
(
'type'
,
'uw_ct_event'
)
->
execute
();
// Load all the blog nodes.
$nodes
=
Node
::
loadMultiple
(
$nids
);
// Step through each of the nodes and remove the sections
// that were locked in fields before. This will only remove
// the layouts for the current revision.
foreach
(
$nodes
as
$node
)
{
// Load the sections.
$sections
=
$node
->
get
(
'layout_builder__layout'
)
->
getSections
();
// If the node has at least 3 sections, remove the
// first and last.
if
(
count
(
$sections
)
>
2
)
{
// Remove first and last section.
unset
(
$sections
[
0
]);
unset
(
$sections
[
count
(
$sections
)]);
// Set the updated sections.
$node
->
layout_builder__layout
->
setValue
(
$sections
);
// Save the node.
$node
->
save
();
}
// Get the node id from the node object.
$nid
=
$node
->
id
();
// Get all the revisions for the nid.
$query
=
\
Drupal
::
database
()
->
select
(
'node_revision'
,
'nr'
);
$query
->
addField
(
'nr'
,
'vid'
);
$query
->
condition
(
'nr.nid'
,
$nid
);
$revisions
=
$query
->
execute
()
->
fetchAll
();
// Step through each of the revisions and remove the sections.
foreach
(
$revisions
as
$revision
)
{
// Get the vid.
$vid
=
$revision
->
vid
;
// Get all the sections for the revision.
$query
=
\
Drupal
::
database
()
->
select
(
'node_revision__layout_builder__layout'
,
'nrlbl'
);
$query
->
addField
(
'nrlbl'
,
'layout_builder__layout_section'
);
$query
->
condition
(
'nrlbl.entity_id'
,
$nid
);
$query
->
condition
(
'nrlbl.revision_id'
,
$vid
);
$sections
=
$query
->
execute
()
->
fetchAll
();
// If the sections are not empty, remove first and last.
if
(
!
empty
(
$sections
))
{
// Get the last section.
$last
=
count
(
$sections
)
-
1
;
// Delete the first section.
$query
=
\
Drupal
::
database
()
->
delete
(
'node_revision__layout_builder__layout'
);
$query
->
condition
(
'entity_id'
,
$nid
);
$query
->
condition
(
'revision_id'
,
$vid
);
$query
->
condition
(
'delta'
,
0
);
$query
->
execute
();
// Delete the last section.
$query
=
\
Drupal
::
database
()
->
delete
(
'node_revision__layout_builder__layout'
);
$query
->
condition
(
'entity_id'
,
$nid
);
$query
->
condition
(
'revision_id'
,
$vid
);
$query
->
condition
(
'delta'
,
$last
);
$query
->
execute
();
}
}
}
}
uw_ct_event.module
View file @
a3351147
...
...
@@ -5,16 +5,17 @@
* Provides configuration and settings for events.
*/
use
Drupal\views\ViewExecutable
;
/**
* Implements hook_preprocess_block().
*
* Remove the exposed widgets from the view/block for events.
* Implements hook_views_pre_render().
*/
function
uw_ct_event_preprocess_block
(
$variables
)
{
// If we are on a events listing, remove the exposed widgets.
if
(
isset
(
$variables
[
'derivative_plugin_id'
])
&&
$variables
[
'derivative_plugin_id'
]
==
'uw_view_events-events_listing_block'
)
{
// Remove the exposed widgets from the view/block.
unset
(
$variables
[
'content'
][
'#view'
]
->
exposed_widgets
);
function
uw_ct_event_views_pre_render
(
ViewExecutable
$view
)
{
// Remove exposed filters on block listing view.
if
(
$view
->
id
()
==
'uw_view_events'
&&
$view
->
getTitle
()
==
'Event listing'
)
{
unset
(
$view
->
exposed_widgets
);
}
}
...
...
@@ -27,26 +28,3 @@ function uw_ct_event_geofield_map_latlon_element_alter(array &$map_settings, arr
$complete_form
[
'#attached'
][
'library'
][]
=
'uw_ct_event/uw_ct_event_edit'
;
}
}
/**
* Implements hook_preprocess_node().
*
* Set variables for teaser.
*/
function
uw_ct_event_preprocess_node
(
&
$variables
)
{
// If we are on a event node that is a teaser,
// get out the variables to be used in pattern-lab.
if
(
$variables
[
'node'
]
->
getType
()
==
'uw_ct_event'
&&
$variables
[
'view_mode'
]
==
'teaser'
)
{
// The UW service object.
$uwService
=
\
Drupal
::
service
(
'uw_cfg_common.uw_service'
);
// Get the teaser variables.
$variables
[
'teaser'
]
=
$uwService
->
uwGetNodeContent
(
$variables
[
'node'
],
'teaser'
,
'all'
);
// Unset the content variable, so that we do not get
// a second print of all the content.
unset
(
$variables
[
'content'
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment