-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[4.1] Images in the Smart Search results #32450
Conversation
Code style still bad, using spaces for indentation, see here https://ci.joomla.org/joomla/joomla-cms/40181/1/6 . Another thing is that 4.0 is already in Beta phase so we have a feature freeze, and this here is a new feature. So this PR should be made for the 4.1-dev branch. |
I see the Intro image in the results list but in one instance followed by an error panel starting: ( ! ) Notice: Undefined variable: extraAttr in /Users/ceford/Sites/joomla-cms-4/components/com_finder/tmpl/search/default_result.php on line 96 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32450. |
Just to be 100% clear. The decision was not to remove all descriptions. The decision was to display descriptions on screen instead of as a popup and only to include descriptions that it was felt were essential. |
@brianteeman Thanks for clarifying and explaining it more precise than I did. It's exactly like you say. |
Now the problem remains that if this is a new feature then it should go into 4.1. @zero-24 What's your opinion? |
Thanks for clarifying @brianteeman. |
That question should be directed at @bembelimen but i personally would agree to move this to 4.1 |
Everyting what is a nice idea and improvement, but does not fix a bug should be 4.1. as we did for example with my pr #32223 |
Sometimes we need to use full article image instead of intro article image. I think this pr should check for full article image also if intro images does not exist. |
I have tested this item ✅ successfully on 50afef0 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/32450. |
Co-authored-by: Richard Fath <[email protected]>
Co-authored-by: Richard Fath <[email protected]>
This reverts commit 8731d82
Co-authored-by: Quy <[email protected]>
50afef0
to
115b924
Compare
please also remove properties, it already handled by __get/__set methods, |
@bembelimen Unfortunately i am not aware of BS5 and the classes that J4 uses in general. I would appreciate it, if someone more knowledgable on that, have a look. Btw. The image uses the "Image Class" property/setting, which was introduced for the joomla content as well (not sure if this is still valid) and is supposed to provide the styling to the image. |
Correct, please read the comment for the method: joomla-cms/administrator/components/com_finder/src/Indexer/Result.php Lines 200 to 214 in 1a6f5ae
Then we will have consistency. This allows us to add any extra value to the result object, without introducing extra properties and getters/setters, for each. |
@@ -48,6 +49,22 @@ | |||
$description = HTMLHelper::_('string.truncate', StringHelper::substr($full_description, $start), $desc_length, true); | |||
} | |||
|
|||
$showImage = $this->params->get('show_image', 0); | |||
|
|||
if ($showImage && !empty($this->result->getElement('imageUrl'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need use empty
check, just do:
if ($showImage && $this->result->imageUrl)
Remember we have a __get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->result->imageUrl
and $this->result->imageAlt
no longer exist, based on the last commit.
The imageUrl and imageAlt are now part of the Joomla\Component\Finder\Administrator\Indexer\Result::$elements
which can only be accessed through the __get()
or the getElement()
functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, do you know what __get()
/__set()
doing? :)
Please check how the code access to $item->title and other values.
$this->result->imageUrl and $this->result->imageAlt no longer exist
Correct, they not need to exist. That is magic of magic methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test your suggestions before writing them down.
$this->result->imageUrl
and $this->result->imageAlt
are null since they do not exist.
If you want to provide a working example based on that suggestion, please commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is null only when it empty,
if you set a value while indexing then it will be not null here
if (!empty($images) && $images->image_intro) | ||
{ | ||
$item->setElement('imageUrl', $images->image_intro); | ||
$item->setElement('imageAlt', $images->image_intro_alt ?? ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look how $item->title
is set, and do the same:
$item->imageUrl = $images->image_intro;
$item->imageAlt = $images->image_intro_alt ?? '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly how it was before pointing me out to use the getters/setters. Probably you are commenting without checking my commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, here it was correct before,
before pointing me out to use the getters/setters
It was about Result class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry i cannot go back and forth. I am closing that as resolved since it works and it's indeed much better than setting public properties. For any further change please commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, title was a bad example sorry, however please do:
$item->imageUrl = $images->image_intro;
$item->imageAlt = $images->image_intro_alt ?? '';
No need to create any properties, just do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously you did not bother to examine the finder's code, neither to test what you are writing.
Since you are wasting my time and i have no appetite to talk with toddlers, i am closing that.
@sakiss You've closed this by purpose or by accident? |
@richard67 on purpose for obvious reasons |
Summary of Changes
The PR allows the use of images in the finder's results.
A new setting was added named "Result Image" both in the com_finder's (aka Smart Search) configuration and it's respective "search" menu item.
Testing Instructions
Actual result BEFORE applying this Pull Request
Expected result AFTER applying this Pull Request
Sidenotes
Atm only the com_content finder plugin uses the images API function. Support for the rest plugins will be added in a next PR.
No styling is added, though a new setting (Image class) is introduced, according to the setting of com_content's config.
If anyone thinks that additional styling should be applied, plz commit.
Documentation Changes Required
DKN