I created a dynamic get of type getCustoms, in it I added code in the custom script -> Add PHP (after getting the Items) section.
After compiling the component I expected getCustoms to work like getListQuery and add the custom script just before "return $items;" , but it wasn't.
Steps to reproduce the Bug
Create dynamic get of type getCustoms
Add your code in custom script tab, section "Add PHP (after getting the Items)"
Compile the component.
Check the model where the code from dynamic get, was added
The custom code was not added just before "return $items;"
Which Joomla version are you compiling in?
5.3.0
Which PHP version are you compiling in?
8.2.23
Which Joomla versions are you targeting?
v5.x
Which PHP version are you targeting?
8.x
Which Web server is JCB running on?
Apache/2.4.62 (Debian)
Which Relational Database is JCB running on?
Mysql, 11.6.2-MariaDB-ubu2404
Which OS is JCB running on?
Ubuntu
Which JCB version are you using?
v5.1.1-alpha5
Where in JCB did this issue occur?
Dynamic Get(admin_view)
On which browsers did you encounter the issue?
Firefox
Additional Comments
...
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 3718] Reset the query using our newly populated query object.
$db->setQuery($query);
$items = $db->loadObjectList();
/***[JCBGUI.dynamic_get.php_after_getitems.44.$$$$]***/
// creat links for items
foreach ($items as $itemKey => $itemValue) {
$items[$itemKey]->link = RouteHelper::getBookchapterRoute($itemValue->slug);
}/***[/JCBGUI$$$$]***/
if (empty($items))
{
return false;
}
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 4427] Insure all item fields are adapted where needed.
if (UtilitiesArrayHelper::check($items))
{
foreach ($items as $nr => &$item)
{
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 4436] Always create a slug for sef URL's
$item->slug = ($item->id ?? '0') . (isset($item->alias) ? ':' . $item->alias : '');
}
}
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 3744] return items
return $items;
### What Happened?
I created a dynamic get of type getCustoms, in it I added code in the custom script -> Add PHP (after getting the Items) section.
After compiling the component I expected getCustoms to work like getListQuery and add the custom script just before "return $items;" , but it wasn't.
### Steps to reproduce the Bug
1. Create dynamic get of type getCustoms
2. Add your code in custom script tab, section "Add PHP (after getting the Items)"
3. Compile the component.
4. Check the model where the code from dynamic get, was added
5. The custom code was not added just before "return $items;"
### Which Joomla version are you compiling in?
5.3.0
### Which PHP version are you compiling in?
8.2.23
### Which Joomla versions are you targeting?
v5.x
### Which PHP version are you targeting?
8.x
### Which Web server is JCB running on?
Apache/2.4.62 (Debian)
### Which Relational Database is JCB running on?
Mysql, 11.6.2-MariaDB-ubu2404
### Which OS is JCB running on?
Ubuntu
### Which JCB version are you using?
v5.1.1-alpha5
### Where in JCB did this issue occur?
Dynamic Get(admin_view)
### On which browsers did you encounter the issue?
Firefox
### Additional Comments
```
...
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 3718] Reset the query using our newly populated query object.
$db->setQuery($query);
$items = $db->loadObjectList();
/***[JCBGUI.dynamic_get.php_after_getitems.44.$$$$]***/
// creat links for items
foreach ($items as $itemKey => $itemValue) {
$items[$itemKey]->link = RouteHelper::getBookchapterRoute($itemValue->slug);
}/***[/JCBGUI$$$$]***/
if (empty($items))
{
return false;
}
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 4427] Insure all item fields are adapted where needed.
if (UtilitiesArrayHelper::check($items))
{
foreach ($items as $nr => &$item)
{
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 4436] Always create a slug for sef URL's
$item->slug = ($item->id ?? '0') . (isset($item->alias) ? ':' . $item->alias : '');
}
}
// [VDM\Joomla\Componentbuilder\Compiler\Helper\Interpretation 3744] return items
return $items;
```
oxido
added the Bug label 2025-06-04 00:59:18 +00:00
oxido
changed title from [BUG]: to [BUG]: dynamic get of type getCustoms do not add the custom code just before "return $items;"2025-06-04 01:02:20 +00:00
oxido
changed title from [BUG]: dynamic get of type getCustoms do not add the custom code just before "return $items;" to [BUG]: can't create slug using dynamic get of type getCustoms, custom code is not added just before "return $items;"2025-07-04 21:32:25 +00:00
Is not a real problem for me right now, I just need to move that piece of custom script a little bit down every time I compile the app.
If this is how it should work, there is no problem, except that in the normal dynamicGet, the custom script is placed just before return $items; , I just assumed that this should be the case in getCustoms as well.
Because the slug is created a little bit down, I can't use it in my custom script.
Is not a real problem for me right now, I just need to move that piece of custom script a little bit down every time I compile the app.
If this is how it should work, there is no problem, except that in the normal dynamicGet, the custom script is placed just before
`return $items; `, I just assumed that this should be the case in getCustoms as well.
Because the slug is created a little bit down, I can't use it in my custom script.
oxido
changed title from [BUG]: can't create slug using dynamic get of type getCustoms, custom code is not added just before "return $items;" to [BUG]: can't create link using dynamic get of type getCustoms, custom code is not added just before "return $items;"2025-07-05 11:51:57 +00:00
This moves the code that is in the php_after_getitems to be below the auto generated loop. Ideal would be that we can in the loop add our code actually. So I will add this to the possible improvement towards the next release. For now this fix should help you, but we might need to do more here, and so you might have to refactor this again with the next stable release.
hmmm lets fix this for you... and we can investigate this to see if this change will work for everyone.
So first... in the crazy file: [Interpretation](https://git.vdm.dev/joomla/Component-Builder/src/commit/e097540a7d8867b5665b08510e91f80fdff085c3/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php#L3705-L3727)
We replace line 3705-3727 with:
```
$main .= PHP_EOL . PHP_EOL . Indent::_(2)
. "if (empty(\$items))";
$main .= PHP_EOL . Indent::_(2) . "{";
$main .= PHP_EOL . Indent::_(3) . "return false;";
$main .= PHP_EOL . Indent::_(2) . "}";
// SITE_GET_ITEMS <<<DYNAMIC>>>
$main .= $this->setCustomViewGetItems($view, $view->code);
// set after items php
if (isset($view->add_php_after_getitems)
&& $view->add_php_after_getitems == 1
&& isset($view->php_after_getitems)
&& StringHelper::check(
$view->php_after_getitems
))
{
$main .= CFactory::_('Placeholder')->update_(
$view->php_after_getitems
);
}
$main .= PHP_EOL . Indent::_(2) . "//" . Line::_(
__LINE__,__CLASS__
) . " return items";
$main .= PHP_EOL . Indent::_(2) . "return \$items;";
```
This should fix the issue for you.
This moves the code that is in the `php_after_getitems` to be below the auto generated loop. Ideal would be that we can in the loop add our code actually. So I will add this to the possible improvement towards the next release. For now this fix should help you, but we might need to do more here, and so you might have to refactor this again with the next stable release.
Llewellyn
added this to the Compiler Improvements project 2025-07-05 15:49:05 +00:00
We should definitely not just move that code down. it would need a new code option added. I for instance use that block in several components to catch an empty case where i don't want
if (empty($items))
{
return false;
}
to happen. for instance now i have a view where if it's empty i want to show the user an onboarding template to get the info required. but if info is present i just want to show the dashboard template.
We should definitely not just move that code down. it would need a new code option added. I for instance use that block in several components to catch an empty case where i don't want
```
if (empty($items))
{
return false;
}
```
to happen. for instance now i have a view where if it's empty i want to show the user an onboarding template to get the info required. but if info is present i just want to show the dashboard template.
Well this method: setCustomViewCustomMethods has been move to its own class, and is completely changed for the better.
Once I have this released, we can look at this again. I think the new class we moved the code to what @oxido asked for, if we must instead add a new code block we will need some more conversation.
Well this [method](https://git.vdm.dev/joomla/Component-Builder/src/commit/e097540a7d8867b5665b08510e91f80fdff085c3/libraries/vendor_jcb/VDM.Joomla/src/Componentbuilder/Compiler/Helper/Interpretation.php#L3579): `setCustomViewCustomMethods` has been move to its own class, and is completely changed for the better.
Once I have this released, we can look at this again. I think the new class we moved the code to what @oxido asked for, if we must instead add a new code block we will need some more conversation.
This is a snippet from the new class:
```
if (
isset($view->add_php_before_getitems)
&& $view->add_php_before_getitems == 1
&& isset($view->php_before_getitems)
&& StringHelper::check($view->php_before_getitems)
) {
$main .= $this->placeholder->update_($view->php_before_getitems);
}
$main .= PHP_EOL . PHP_EOL . Indent::_(2) . "//" . Line::_(__LINE__, __CLASS__) . " Reset the query using our newly populated query object.";
$main .= PHP_EOL . Indent::_(2) . "\$db->setQuery(\$query);";
$main .= PHP_EOL . Indent::_(2) . "\$items = \$db->loadObjectList();";
$main .= PHP_EOL . PHP_EOL . Indent::_(2) . "if (empty(\$items))";
$main .= PHP_EOL . Indent::_(2) . "{";
$main .= PHP_EOL . Indent::_(3) . "return false;";
$main .= PHP_EOL . Indent::_(2) . "}";
$main .= $this->getitems->get($view, $view->code);
if (
isset($view->add_php_after_getitems)
&& $view->add_php_after_getitems == 1
&& isset($view->php_after_getitems)
&& StringHelper::check($view->php_after_getitems)
) {
$main .= $this->placeholder->update_($view->php_after_getitems);
}
$main .= PHP_EOL . Indent::_(2) . "//" . Line::_(__LINE__, __CLASS__) . " return items";
$main .= PHP_EOL . Indent::_(2) . "return \$items;";
```
Please note: In the latest JCB releases we have massively refactored the Interpretation and Infusion classes, with lot of improvements and many functions have moved to their own classes.
See CHANGELOG
This issue can be closed.
Please note: In the latest JCB releases we have massively refactored the Interpretation and Infusion classes, with lot of improvements and many functions have moved to their own classes.
See [CHANGELOG](https://git.vdm.dev/joomla/Component-Builder/src/branch/6.x/CHANGELOG.md)
This issue can be closed.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What Happened?
I created a dynamic get of type getCustoms, in it I added code in the custom script -> Add PHP (after getting the Items) section.
After compiling the component I expected getCustoms to work like getListQuery and add the custom script just before "return $items;" , but it wasn't.
Steps to reproduce the Bug
Which Joomla version are you compiling in?
5.3.0
Which PHP version are you compiling in?
8.2.23
Which Joomla versions are you targeting?
v5.x
Which PHP version are you targeting?
8.x
Which Web server is JCB running on?
Apache/2.4.62 (Debian)
Which Relational Database is JCB running on?
Mysql, 11.6.2-MariaDB-ubu2404
Which OS is JCB running on?
Ubuntu
Which JCB version are you using?
v5.1.1-alpha5
Where in JCB did this issue occur?
Dynamic Get(admin_view)
On which browsers did you encounter the issue?
Firefox
Additional Comments
[BUG]:to [BUG]: dynamic get of type getCustoms do not add the custom code just before "return $items;"[BUG]: dynamic get of type getCustoms do not add the custom code just before "return $items;"to [BUG]: can't create slug using dynamic get of type getCustoms, custom code is not added just before "return $items;"Give us some screen shots of each tab you are using in the Dynamic get area... so I can explain to you what you can do to get the expected outcome,
Is not a real problem for me right now, I just need to move that piece of custom script a little bit down every time I compile the app.
If this is how it should work, there is no problem, except that in the normal dynamicGet, the custom script is placed just before
return $items;, I just assumed that this should be the case in getCustoms as well.Because the slug is created a little bit down, I can't use it in my custom script.
[BUG]: can't create slug using dynamic get of type getCustoms, custom code is not added just before "return $items;"to [BUG]: can't create link using dynamic get of type getCustoms, custom code is not added just before "return $items;"hmmm lets fix this for you... and we can investigate this to see if this change will work for everyone.
So first... in the crazy file: Interpretation
We replace line 3705-3727 with:
This should fix the issue for you.
This moves the code that is in the
php_after_getitemsto be below the auto generated loop. Ideal would be that we can in the loop add our code actually. So I will add this to the possible improvement towards the next release. For now this fix should help you, but we might need to do more here, and so you might have to refactor this again with the next stable release.It is working.
We should definitely not just move that code down. it would need a new code option added. I for instance use that block in several components to catch an empty case where i don't want
to happen. for instance now i have a view where if it's empty i want to show the user an onboarding template to get the info required. but if info is present i just want to show the dashboard template.
Well this method:
setCustomViewCustomMethodshas been move to its own class, and is completely changed for the better.Once I have this released, we can look at this again. I think the new class we moved the code to what @oxido asked for, if we must instead add a new code block we will need some more conversation.
This is a snippet from the new class:
Please note: In the latest JCB releases we have massively refactored the Interpretation and Infusion classes, with lot of improvements and many functions have moved to their own classes.
See CHANGELOG
This issue can be closed.