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 avoid duplicate content using .htaccess
How to remove newline character in PHP
How to install apache, php, mysql with macport in Mac OS X
Password protect directory with .htaccess and .htpasswd
WordPress: add javascript event after widget save
How to convert Youtube video to IPod / IPhone (mp4)
Bootstrap 3: Responsive image align center
Share this with your friends:-