Posted: October 2, 2016 at 4:04 am
|
Hi, I need to limit the columns generated by exporting the CSV file an event. I have reviewed the forums but have not found a solution that works. My programming skills are somewhat limited. My version is EE4. Excuse my English. Greetings. |
Hi Manuel, We have a filter that allows you to set which fields are allowed within the CSV here: You can add that to a Custom Functions Plugin on your site to do what you need. The list of column names are what will be allowed through to the CSV, if you loow at the top of the CSV that you have currently you will find the column names, add the ones you want to include to the above function. |
|
|
OK, thanks for the reply. regards |
|
Hi, I have completed the steps and when I generate the CSV file with the list of records creates the 4 columns but the data appears empty (no name, email …). As I can fix to fill the fields with the data of registered Users are recommended? Greetings. |
Hello, Could you upload your version of the FHEE__EE_Export__report_registrations__reg_csv_array (https://github.com/eventespresso/ee-code-snippet-library/blob/master/admin/registration_report_limit_columns_shown.php) to something like pastebin or GitHub gist and share here so we can share feedback? — |
|
|
Hello, I uploaded the code I used to see where the error may be. Thank you. |
Hi Manuel, The reason it’s not working for you is because the field names were translated. The translation functions will take care of translating the strings before they’re sent to the CSV. So basically where you have this:
You’ll need to change it to be this:
|
|
|
Hi, I modified the code to generate the CSV but the fields are not filled as it does with the original code. I put a sample image. |
Hi there, Using the translated strings within the function works fine however your strings MUST match the CSV output fields exactly (yours did not). You also don’t need to run translated strings through the translation function again when doing that. The problem with the current setup is the translations don’t match the values within the CSV array, so these fields:
Don’t match any of the fields available within the CSV array because they include the DB field name within the translation. The above needs to be changed to:
Because EE is translating the field name, then appending the DB field to the translation, but the example function is translating the field name including the DB field, which will never match anything. So we need to translate the field name, then add the DB field name to the end so that the full field name matches what is in the array. Make sense? The other option you have is to skip the translation within the function and just add the full field names you want to include in the CSV. So you look within the CSV, find the field name and add that to the function directly. For example, here is a CSV I generated using the above code – http://take.ms/vpEeP So the three fields I want are So lets use those directly within the function:
As mentioned you don’t need to run those fields through the translate function __() again because you have translated them yourself. That then exports the fields in the exact same way as above with the fixed snippet. |
|
Also the reason this:
did not work is because the strings don’t match the CSV titles – http://take.ms/RRcdD The strings you have set do not match the strings in the CSV, there is a space before the DB Field name and your using different text than your fields are. For those 3 fields, this would have worked:
However please read my above reply as it explains further. |
|
The support post ‘Limit columns csv EE4’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.