Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3076: ding webtrekk fixes #928

Closed
wants to merge 5 commits into from

Conversation

holt83
Copy link
Member

@holt83 holt83 commented Dec 12, 2017

https://platform.dandigbib.org/issues/3076

OSS parameters was added twice because of the changes in https://platform.dandigbib.org/issues/629.

Updated the page titles also. Before the page title for Search node, was ding_multiple_search.

Also includes the fix to track empty searches.

@holt83
Copy link
Member Author

holt83 commented Dec 12, 2017

Regarding the "OSS parameters was added twice":

I see there was added some checks to prevent this, but the problem was that OSS tracking for node search was added in search ting page also, because of changes in https://platform.dandigbib.org/issues/629.

@@ -80,8 +80,7 @@ function ding_webtrekk_panels_pane_content_alter($content, $pane, $args, $contex
* Track internal search results.
*/
function ding_webtrekk_views_post_execute(&$view) {
$count = $view->total_rows;
if ($view->name == 'ding_multiple_search' && $count > 0) {
if ($view->name == 'ding_multiple_search' && strpos(current_path(), 'search/node') === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the current path check here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because else it's added on ting search page also because of https://platform.dandigbib.org/issues/629

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Then I would appreciate a comment explaining this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah sorry, of course. Coming up :)

@@ -62,10 +62,10 @@ function ding_webtrekk_page_alter(&$page) {
* Track ting search results.
*/
function ding_webtrekk_panels_pane_content_alter($content, $pane, $args, $contexts) {
if ($pane->type == 'search_result' && $pane->configuration['type'] == 'ting_search') {
if ($pane->type == 'search_result' && $pane->configuration['type'] == 'ting_search' && strpos(current_path(), 'search/ting') === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combination of the implemented hook and the dependency on the current path does not seem right. The reliance on panes seems to be unnecessary noise.

How about using another hook instead and just checking whether drupal_static('ting_search_results', FALSE) is set? Perhaps hook_page_alter is really the way to go. Another approach could be hook_search_page

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, this was the way it was done in the old module. Just wanted to ensure that it only gets added on the correct page.

Copy link
Member Author

@holt83 holt83 Dec 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly it was done this way because of:

  1. the search_result pane can be configures to use other "search types".
  2. drupal_static('ting_search_results', FALSE) might be set in other pages than the ting_search page.
  3. The current path check is there to aviod it being added on other pages, where the search wasn't triggered by a user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static variable drupal_static('ting_search_results', FALSE) is set in ting_search_search_execute. So maybe it's safe to check for it in hook_page_alter.

Should I make this update and remove hook_panels_pane_content_alter() all together?

Just have the feeling that I forgotten something and it was made this way for a reason (made it myself, but can't remember tbh)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into hook_search_page. It seems it's only invoked on the module implementing the search type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@holt83: Then I think we should switch to hook_page_alter and check current path. hook_panels_pane_content_alter() can be removed entirely.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I will update PR with this approach

@holt83
Copy link
Member Author

holt83 commented Dec 12, 2017

@kasperg I updated the PR with the suggested changes.

I tried my best to make helpful comments. Let me know if they don't make sense or if you have suggestions for improvements :)

Copy link
Member

@kasperg kasperg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@kasperg kasperg changed the base branch from master to release-4.1.x December 12, 2017 16:53
@kasperg kasperg changed the base branch from release-4.1.x to master December 12, 2017 16:59
@kasperg
Copy link
Member

kasperg commented Dec 12, 2017

Approved - but branched from wrong master instead of release-4.1.x. I cherry picked commits manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants