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

Allow help text to be overridden from an .extra.hlp file #13488

Merged
merged 2 commits into from
Jan 31, 2019

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jan 20, 2019

Overview

Help text is written in .hlp smarty files. You can append to the text by adding your own .extra.hlp file with the same name. This allows you to also override it.

NOTE the pageRun hook is removed from CRM_Core_Page_Inline_Help in this PR. Per discussion - see #13488 (comment)

Before

.extra.hlp files could append but not override help text.

After

.extra.hlp files can be set to override on a per-item basis.

How-to

  1. Create an extension (and enable it)

  2. Add a file: templates/CRM/Activity/Form/Activity.extra.hlp

  3. Add this to the file:

     {htxt id="assignee_contact_id" override=1}
       <p>I'm extra!</p>
     {/htxt}
    
  4. Go to the "new activity" screen and click the help icon for "Assigned to"

  5. Note that the default help text is gone and only the text "I'm extra!" prints.

  6. If you remove the overrride=1 param, both the default help text and the new text appear, which was the previous behavior.

@civibot civibot bot added the master label Jan 20, 2019
@civibot
Copy link

civibot bot commented Jan 20, 2019

(Standard links)

@monishdeb
Copy link
Member

Tested working fine. Here's a screencast as 'How-to' steps:
after

On the other hand, I encountered a separate issue which is caused by pageRun hook. Suppose some extension called a $page->getVar() inside a pageRun hook then it throws a internal error when we click on hlp icon as:

<em class="placeholder">Error</em>: Call to undefined method CRM_Core_Page_Inline_Help::getVar() in <em class="placeholder">shoreditch_civicrm_pageRun()</em> (line <em class="placeholder">156</em> of <em class="placeholder">/Users/monish/src/civi-extensions/org.civicrm.shoreditch/shoreditch.php</em>).

In this above example the error is generted from here as CRM_Core_Page_Inline_Help don't extend CRM_Core_Page this it don't inherit getVar() as triggered from here

@colemanw
Copy link
Member Author

Hmm. If the pageRun hook doesn't actually work (and wasn't running anyway 99% of the time) maybe we should just remove it.

@colemanw
Copy link
Member Author

Looking at the commit history, that hook invocation was added in 6eea17d and @eileenmcnaughton references https://issues.civicrm.org/jira/browse/CRM-14021 in the commit msg. However, that issue description makes no mention of the hook, so I'm guessing she added it as an afterthought rather than because it was actually needed for something. As @monishdeb noted, the way it's invoked makes it very unlikely to be useful to anyone.

@eileenmcnaughton can you confirm it's safe to remove?

@monishdeb
Copy link
Member

monishdeb commented Jan 21, 2019

I agree with removing the Hook call in CRM_Core_Page_Inline_Help, but will wait for @eileenmcnaughton reply if theres any unwanted side effect to extensions, if we remove the hook call

@seamuslee001
Copy link
Contributor

@monishdeb @colemanw I believe I am currently using the pageRun hook to manipulate the event info page. As such I would be against removing it. I would note that the hook doc iirc mentions it doesn’t run on forms only quickform pages

@colemanw
Copy link
Member Author

colemanw commented Jan 21, 2019

@seamuslee001 we're not proposing to remove the entire hook. Just to stop invoking it in this one place when displaying help bubbles. This hook invocation is inconsistent and problematic because:

  • The help page is not actually a CRM_Core_Page so the signature is broken.
  • The hook only fires in the unusual circumstance of a .extra.hlp file existing.

I expect that removing it here will affect precisely no one. But will wait for @eileenmcnaughton to weigh in.

@seamuslee001
Copy link
Contributor

Ah on that would be ok then. I miss interpreted Monish’s statement when he said he was ok removing the hook I thought that was completely removing not just one invocation.

@monishdeb
Copy link
Member

@seamuslee001 I realized it and so I edited my comment soon after I saw your comment. Sorry about that :(

@colemanw
Copy link
Member Author

@civicrm-builder retest this please

@eileenmcnaughton
Copy link
Contributor

I can't recall anything about this!

I suspect the reason for the hook call is to allow extra variables to be assigned but I also think the discussion here is probably enough to warrant removing it but we should flag it in the hook change log & make sure the overview marks it such that it gets picked up as a change to highlight in release notes

@colemanw colemanw added the merge ready PR will be merged after a few days if there are no objections label Jan 29, 2019
@colemanw
Copy link
Member Author

Thanks Eileen.
Marking this as merge-ready pending a green light from @lcdservices

@lcdservices
Copy link
Contributor

@colemanw @eileenmcnaughton tested and this looks good. Implemented an extension to handle all inline help modifications.

@eileenmcnaughton
Copy link
Contributor

@colemanw do you want to update the change log as we merge this?

@colemanw colemanw merged commit 49853fd into civicrm:master Jan 31, 2019
@colemanw colemanw deleted the helpOverride branch January 31, 2019 15:04
@colemanw
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants