-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
JLayout system improvements / fixes #8234
Conversation
I'm going to remove the debug requirement to render debug messages because it doesn't really improve performance and causes tests to fail. |
PR is currently failing because of downtime in pecl.php.net - as you can see the rest of the tests pass in other PHP versions - so assume they will pass in 5.5 and 5.6 for now and we will restart the build when it comes online |
I have tested this item ✅ successfully on 825719f Tested in my own module which currently is forced to override JLayoutFile to change the include paths (https://github.com/JoomJunk/shoutbox/blob/development/mod_shoutbox/libraries/layout.php) and tested replacing it with Enabled Debug mode and successfully observed the debug html comments - which are actually a great idea. Kunena use a similar concept which is super useful Overall really useful and a successful test. Thanks @phproberto This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8234. |
I have tested this item ✅ successfully on 825719f I have just send a quick CS PR here: phproberto#3 if we can get that in we can move this RTC. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8234. |
Update file.php Update file.php
This PR has received new commits. This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8234. |
Thanks @phproberto -> RTC This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8234. |
JLayout system improvements / fixes
This PR tries to improve & fix some issues in the curre JLayout system
Index
1.1. [fix] Custom include paths cannot be used.
2.1. [imp] Add method to clear include paths (clearIncludePaths())
2.2. [imp] Add method to get active include paths (getIncludePaths())
2.3. [imp] Make JLayout methods chainable when possible.
2.4. [imp] Allow to set data variables before rendering the layout
2,5. [imp] Add method to clear the debug messages (clearDebugMessages())
2.6. [imp] Add a cache system to avoid duplicates file searches
2.7. [imp] Add HTML comment to the start & end of layouts when Joomla debug mode is enabled
2.8. [imp] Add support for automatic language suffixes
2.9. [imp] Add support for automatic version suffixes
2.10. [imp] Add a method to get the active layout id
2.11. [imp] Add a method to get the active suffixes
2.12. [imp] Add a method to check if debug is enabled
2.13. [imp] Add fast methods to debug layouts
2.14. [imp] Avoid adding debug messages if debug is disabled1. Fixes
1.1. [fix] Custom include paths cannot be used.
Currently there is a fix that makes that includePaths cannot be changed by developers. See #3451
This was caused because the refreshIncludePaths() method was called always on render method. Not the logic attached to load the default include paths is only triggered when there are no includePaths explicilty defined.
Now you can use different methods to set the include paths:
2. Improvements
2.1. [imp] Add method to clear include paths
Now there is a method to clear the list of include paths. Usage:
2.2. [imp] Add method to get active include paths
Now we can get the list of active paths that are going to be used to render a layout:
2.3. [imp] Make JLayout methods chainable when possible.
This allows a more dynamic way of setup layouts. Examples:
2.4. [imp] Allow to set data variables before rendering the layout
Most rendering systems include a way to dynamically set & set data. Now you can do it like:
Note that to be able to use the set & get methods the data passed to layouts has to be ALWAYS AN ARRAY. Otherwise the system will only use the data received in the render method to keep B/C.
2.5. [imp] Add method to clear the debug messages
Now debug messages can be cleared dynamically with
$layout->clearDebugMessages()
. Now that method is only used internally but may be useful even if it's only to people extending JLayoutFile2.6. [imp] Add a cache system to avoid duplicates file searches
Now all the file searches are cached by the system so if the same layout is searched in the same include paths and with the same suffixes it will return a cached path.
2.7. [imp] Add HTML comment to the start & end of layouts when Joomla debug mode is enabled.
This was a proposal by @javigomez and I found it really useful for frontenders I've been working with. When debug mode is enabled from backend joomla configuration all the layouts will have an HTML comment before and one HTML after.
Something like:
2.8. [imp] Add support for automatic language suffixes
Now there is a method to automatically load suffixes based on the active language. Usage:
2.9. [imp] Add support for automatic version suffixes
I added also a method to generate automatic suffixes based on the version of the system. Usage:
2.10. [imp] Add a method to get the active layout id
Sometimes is useful to know the id of the layout being rendered. I added a method to do it. Sample usage:
I have also deprecated the old
setLayout()
method in favour ofsetLayoutId()
so describes better what it does.2.11. [imp] Add a method to get the active suffixes
Returns an array of loaded suffixes. Sample usage:
2.12. [imp] Add a method to check if debug is enabled
Now there is also a method to check if debug is enabled. It makes sense mainly for internal use. Sample usage:
Also there is now a method to change debug mode without adding the debug setting to the options :
2.13. [imp] Add fast methods to debug layouts
Additionally there are new methods to fastly debug a layout.
There is also a new method in the
JLayoutHelper
class:So only replacing the render with debug you see the output with the debug info.
2.14. [imp] Avoid adding debug messages if debug is disabledThis has been removed because it causes tests to fail and there is no time before v3.5
This was a request from @alex-filat
Now the debug messages are only added and returned when debug is enabled.