Skip to content

[fix] Custom field "list of images" doesn't show directories properly #16708#17125

Closed
eshiol wants to merge 2 commits intojoomla:stagingfrom
eshiol:#16708
Closed

[fix] Custom field "list of images" doesn't show directories properly #16708#17125
eshiol wants to merge 2 commits intojoomla:stagingfrom
eshiol:#16708

Conversation

@eshiol
Copy link
Copy Markdown
Contributor

@eshiol eshiol commented Jul 13, 2017

Pull Request for Issue #16708

Summary of Changes

This patch fixes JFormFieldFolderList. See: #16708

Testing Instructions

#16708 This patch should fix this behavior

Expected result

Field "list of images" works correctly.

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jul 13, 2017

This would always set the path to the root and not respect the configruation.

@eshiol
Copy link
Copy Markdown
Contributor Author

eshiol commented Jul 13, 2017

This sets the path to the directory passed via configuration starting from the root directory.

$path = $this->directory;
$path = JPATH_ROOT . '/' . $path;

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jul 13, 2017

Ah looks like i have not looked close enough.

@zero-24
Copy link
Copy Markdown
Contributor

zero-24 commented Jul 13, 2017

Can you please include a issue description + test instructions?

@eshiol
Copy link
Copy Markdown
Contributor Author

eshiol commented Jul 14, 2017

I wrote a test component called com_pr17152
com_pr17125-3.7.3.3.zip
It creates a folder called "this is the right folder" in the folder components/com_pr17125 and a folder called "this is the wrong folder" in the folder administrator/components/com_pr17125.
In the configuration page you can choose the folder using a folder list field
<field name="file_path" type="folderlist" directory="components/com_pr17125" hide_none="true" hide_default="true" recursive="false" label="folder" description=""/>

Steps to reproduce the issue

Install the component com_pr17125
Go to Components > PR# 17125 > TEST

Expected result

The field should show the contents of the folder components/com_pr17125
image

Actual result

The field shows the contents of the folder administrator/components/com_pr17125
image

Testing Instructions

Install the patch PR# 17125
Go to Components > PR# 17125 > TEST

@joomla joomla deleted a comment from joomla-cms-bot Jul 14, 2017
@joomla-cms-bot joomla-cms-bot changed the title fix #16708 [fix] Custom field "list of images" doesn't show directories properly #16708 Nov 5, 2017
@ghost
Copy link
Copy Markdown

ghost commented Nov 5, 2017

@eshiol can you please update Test Instructions in first Comment?

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Apr 23, 2018

@laoneo Would this be a valid fix to always look in the root directory for images? Currently, it is relative so if there is an images in administrator, then it will look there and not in the root.

@laoneo
Copy link
Copy Markdown
Member

laoneo commented Apr 23, 2018

Not in the folderlist field, otherwise we would have here a BC break. If you need that case, then I would do your own form field for the imegelist custom field.

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Apr 24, 2018

@laoneo Please confirm to close this PR for a different solution.

@laoneo
Copy link
Copy Markdown
Member

laoneo commented Apr 25, 2018

@Quy if the author is willing to implement a form field for the image list custom field in this pr then we can work it out here. Otherwise it should be closed.

@laoneo
Copy link
Copy Markdown
Member

laoneo commented Apr 25, 2018

Why we have a BC break can be reproduced with the following steps:

  • Add the following code to the file administrator/components/com_content/config.xml after line 7
    <field name="file_path" type="folderlist" directory="help" hide_none="true" hide_default="true" recursive="false" label="Help" description=""/>
  • Open the Article Manager options

Actual result

The en-GB folder is shown:
image

Result with patch

Warning and the select box is empty
image

@eshiol
Copy link
Copy Markdown
Contributor Author

eshiol commented Apr 26, 2018

I'm not be able to change the code. I lost the branch.
This code should solve the BC break

		if (!is_dir($path) || is_dir(JPATH_ROOT . '/' . $path))
		{
			$path = JPATH_ROOT . '/' . $path;
		}

By removing is_dir($path) the behavior will change slightly but the function still works

		if (is_dir(JPATH_ROOT . '/' . $path))
		{
			$path = JPATH_ROOT . '/' . $path;
		}

If the path doesn't exist, in the first case the error is related to JPATH_ROOT . '/' . $path, as it is now;
image
in the second one, the error is related to $path
image

@Quy
Copy link
Copy Markdown
Contributor

Quy commented Apr 30, 2018

@eshiol I am sorry if this is not the right way. I would close this PR and submit a new PR with the latest changes.

@eshiol
Copy link
Copy Markdown
Contributor Author

eshiol commented May 4, 2018

replaced by #20294

@eshiol eshiol closed this May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants