If you are using admin generator in symfony 1.4, i bet you will have the problem to customize admin generator listing to show data from foreign table. It’s common for us to display data from different tables within a listing.
To customize admin generator listing to show foreign tables data, follow the steps below:-
Advertisements
- Let’s say we have 2 tables user_logins and user_profiles tables that store user login and their profile details.
- I’ve a user_login module that generated thru the admin generator
- Now i want to customize my admin generator listing to display some user_profiles data. Let say we only want to display 3 columns in our listing eg: user_id, user_name, user_profile_gender
- To do this, first we need to edit the generator.yml
list: display: [user_id, user_name, _user_profiles]
* if you notice, i put a underscore at the user_profiles field.
- Now create a file name it _user_profiles.php in the module templates directory with the content below:-
<?php echo $user_login->getUserProfile()->getGender(); ?>
* Make sure you declare the correct relationship between the user_login and user_profiles table. else you will get error when you call getUserProfile().
- Now, refresh your user_login module listing and you should see the gender is displayed within the listing.
* there might be a better solution out there, if you found one remember to share with the others!
Related posts:
PHP: How to convert ISO character (HTMLEntities) to UTF-8?
Prestashop: How to disable ajax add to cart?
How to configure Thunderbird for IMAP email?
How to disable directory browsing using .htaccess - Apache Web Server
Track Your Website Visitor With Free Invisible Website Tracker - StatCounter
How to migrate mail from CPanel to Google App Mail?
How to setup free Yahoo POP3 email
How to hide apache2 version number in error page
Share this with your friends:-