Custom code to pre-generated code #30
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: joomla/Component-Builder#30
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Component Builder creates a lot of the code automatically. But, what would you need to do if you wanted to extend some of the code that is generated by component builder? For example, a piece of code that I need to get into the code in a particular area, in the site model:
$item->slug = (isset($item->alias)) ? $item->id.':'.$item->alias : $item->id;
This below needs to be a part of that array:
Once generated, the array would need to look like:
The best way to do that in the admin-view, is in the tab called
PHP
there is a list of switches, look forAdd PHP (getItem Method)
You will see it has a hint, that says:
// PHP Here that should run in the getItem Method (object) $item is where all values are
So you can do the following there:
Or in a site-view you will add the code to the dynamic get area (of the main-get) , so you open the dynamic get and look for the tab called
Custom Script
now depending if it is a list query or a get item the switch will be different.list query => Add PHP (after getting the Items)
get item => Add PHP (after getting the Item)
You will see that the note shows the targeting variable name. Let me know if you still having trouble.