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:
Meebo - The Ultimate Web base Instant Messenger powered by AJAX
How to remove Powered By Prestashop footer link
Speed Up and Save Your Website Bandwidth with GZip Compression
How to migrate mail from CPanel to Google App Mail?
Bootstrap - The Responsive Framework
phpmyadmin disable 1440 timeout with auto login
How to add social bookmark link to your Blogger.com blog
Create Gmail with plus addressing to prevent spam
Share this with your friends:-