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

Check for custom Templates in Global Search #9323

Closed

Conversation

JimMackin
Copy link
Contributor

Description

The global search (elastic specifically) uses hard coded templates which makes this functionality hard to customise. This change adds a check for custom files similarly to how other parts of the CRM do.

Motivation and Context

To allow customising the Search templates for the search form and results

How To Test This

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Final checklist

  • My code follows the code style of this project found here.
  • My change requires a change to the documentation.
  • I have read the How to Contribute guidelines.

jack7anderson7
jack7anderson7 previously approved these changes Nov 16, 2021
@jack7anderson7 jack7anderson7 added the Status:Assessed PRs that have been tested and confirmed to resolve an issue by a core team member label Nov 16, 2021
Copy link
Contributor

@clemente-raposo clemente-raposo left a comment

Choose a reason for hiding this comment

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

changes look ok

lib/Search/UI/SearchFormView.php Outdated Show resolved Hide resolved
jack7anderson7
jack7anderson7 previously approved these changes Jul 25, 2022
@clemente-raposo
Copy link
Contributor

@jack7anderson7 commits need the issue number?

@JimMackin could we squash some of the commits?

Copy link
Contributor

@clemente-raposo clemente-raposo left a comment

Choose a reason for hiding this comment

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

LGTM

@jack7anderson7 jack7anderson7 added Status: Requires Testing Requires Manual Testing Status: Passed Code Review Mark issue has passed code review reviewed labels Sep 25, 2023
@johnM2401 johnM2401 added the Status:Requires Updates Issues & PRs which requires input or update from the author label Oct 16, 2023
@johnM2401
Copy link
Contributor

Hey folks!

I've had a look at this, but it appears as though the Search Form returns a Fatal error if no custom files are found.

As this would be the default state, this seems like it may be an issue:

image
image

Additionally, it seems to be searching in [CRM]/lib/Search/UI/custom/templates/
Rather than [CRM]/custom/xxxxxxxx

Is this expected?

Thanks!

@serhiisamko091184 serhiisamko091184 added the Status: Stale For issues & PRs that have had no activity label Mar 18, 2024
@serhiisamko091184
Copy link
Contributor

Hello, @JimMackin

The PR has been marked as stale because there has been no recent activity. It will be closed if no further activity occurs.
Thanks for your contributions.

Regards,
Serhii

@pgorod
Copy link
Contributor

pgorod commented Mar 18, 2024

@johnM2401 you said it returns a fatal error. What is the text of that error?

This should be easy to fix, we might as well just get it done

@johnM2401
Copy link
Contributor

Hey @pgorod !

The FATAL errors appear to be:

Tue Mar 19 12:31:38 2024 [14213][1][FATAL] [ERROR] [SearchThrowableHandler] An unknown error has occurred while performing the search.
Tue Mar 19 12:31:38 2024 [14213][1][FATAL] [ERROR] [SearchThrowableHandler]  --> Smarty: Unable to load template 'file:/var/www/suitecrm_git/lib/Search/UI/custom/templates/search.form.tpl' <-- 

I've also recorded a quick gif to show this:
wontLoadWithoutCustom

Initially, the Search Results page fails to render, as the/lib/Search/UI/custom/templates/ directory does not contain the search.form.tpl file.

After copying the OOTB search.form.tpl file into this folder, Search functionality returns.

(Interestingly, an absent custom/xxxx/search.results.tpl file does not affect this)

Hopefully this helps!
Thanks for pinging this!

@pgorod
Copy link
Contributor

pgorod commented Mar 19, 2024

I guess the call to get_custom_file_if_exists is still not right.

Maybe try this, without any relative paths (are they needed?)

parent::__construct(get_custom_file_if_exists('lib/Search/UI/templates/search.form.tpl')); 

@serhiisamko091184 serhiisamko091184 removed the Status: Stale For issues & PRs that have had no activity label May 1, 2024
@serhiisamko091184
Copy link
Contributor

Hello all!

I'm for this option:
image

It seems logical to have all the customisations in one particular place, in this case, I suggest slightly another changes:

class SearchFormView extends View
{
    public function __construct()
    {
        $tplFile = get_custom_file_if_exists('templates/search.form.tpl');

        str_begin($tplFile, 'custom/') ? parent::__construct($tplFile) : parent::__construct(__DIR__ . $tplFile);
    }

Thanks!

Regards,
Serhii

@serhiisamko091184 serhiisamko091184 added Status: Stale For issues & PRs that have had no activity and removed Status:Requires Updates Issues & PRs which requires input or update from the author labels Oct 3, 2024
@serhiisamko091184
Copy link
Contributor

Hello all!

As the communication has stopped at some point in this PR, I've just marked this one as Stale and recreated it:
#10536

One more time - thanks to @JimMackin for raising the issue and suggesting the fix!

Many thanks!

Regards,
Serhii

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Branch:Hotfix Status:Assessed PRs that have been tested and confirmed to resolve an issue by a core team member Status: Passed Code Review Mark issue has passed code review reviewed Status: Requires Testing Requires Manual Testing Status: Stale For issues & PRs that have had no activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants