VZ Tabular
ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5
Back to this add-on's main page
View Other Add-ons From Eli Van Zoeren
Saving CSV includes HTML tags
Support Request
DanTreasure
|
Posted: 06 January 2016 09:54 AM |
|
|
|
Hi,
I have used the recommended mark-up for generating a CSV output (see attached “Z Tabular mark-up.png”) which works great however when I save it down, change the extension from .html to .csv and open it in Excel, the first and last rows include HTML tags (see attached “Z Tabular CSV output includes HTML.png”).
Is there a way to prevent this from happening? Or can you suggest a better way of implementation?
Thanks in advance,
Dan
|
|
|
Eli Van Zoeren
|
Posted: 06 January 2016 11:18 AM |
# 1
|
|
Developer
|
Hi Dan,
If you are trying to download a copy of the CSV file (rather than displaying it in the browser), you’ll want to use the filename parameter. That will give you clean data without any HTML.
{exp:vz_tabular:csv filename="xyz.csv"} ... {/exp:vz_tabular:csv}
Let me know if that solves it for you, or if you need any more assistance!
-E
|
|
|
DanTreasure
|
Posted: 08 January 2016 10:44 PM |
# 2
|
|
|
Awesome, thanks Eli - that worked great! However, this appears to have introduced another issue -
I’m using category conditionals in Low Variables to determine the URL and the property Type. For example:
{categories} {if category_id == "2"}{url_title_path='for-sale-development/details'}{/if} {if category_id == "3"}{url_title_path='for-sale/details'}{/if} {if category_id == "4"}{url_title_path='sold/details'}{/if} {if category_id == "5"}{url_title_path='for-rent/details'}{/if} {if category_id == "6"}{url_title_path='rented/details'}{/if} {/categories}
And…
{categories}{if category_id == "4" OR category_id == "5" OR category_id == "6"}{category_name}{if:else}For Sale{/if}{/categories}
The above conditionals output fine before the inclusion of filename=“xyz.csv”. However, when I include the filename attribute the CSV output for any snippet that uses the category conditionals outputs as follows:
{!-- ra:000000003502d586000000000910b9e0 --}http://reval.com.au/for-rent/details/13-frost-st-mount-gravatt-east-qld-4122{!--
And…
{!-- ra:000000003502d58e000000000910b9e0 --}For Rent{!-- ra:000000003502d58f000000000910b9e0 --}
See attached “Output-CSV-encoding-problem.png” for a visual reference. I have also attached an example of the CSV output.
Any thoughts on how to resolve this encoding issue?
Thanks,
Dan
File Attachments
|
|
|
Eli Van Zoeren
|
Posted: 11 January 2016 10:03 AM |
# 3
|
|
Developer
|
It looks like you are running into EE’s infamous parse-order. I don’t understand exactly where that {categories} tag is coming from in your template, but it is being parsed *after* the CSV is already generated and downloaded. If that is really coming from Low Variables somehow, Low has a useful reference here: http://gotolow.com/blog/parse-order-and-low-variables. (VZ Tabular runs as a plugin, at stage 5.)
Otherwise, if you want to stick your whole template in a Gist, I might be able to get a better handle on what is going on and give you some direction on how to get around it.
|
|
|
DanTreasure
|
Posted: 12 January 2016 07:52 AM |
# 4
|
|
|
Thanks for getting back to me Eli.
The category conditionals have been added in Low Variables as a snippet (see attached screenshot “Prop CSV LowVariables.png”). I also thought it must have been a parsing issue however have tried referencing the snippet as a Parse tag, Single tag and Pair tag.
For example, using a Pair tag:
{exp:low_variables:pair var="lv_csv_prop_list_links"}{/exp:low_variables:pair}
The result of using the LV tags syntax was the data outputted as the raw conditional. See attached “Category conditional pair tag lv.png”.
When I add the category conditional directly within the VZ Tabular mark-up, the output works correctly (see attached screenshot “category conditional used directly in VZ Tabular.png”). Although this works, it’s not exactly the best result as it’s no longer as modular. Do you have an example of using conditional categories within a Low Variable snippet in VZ Tabular with the “filename” attribute?
As mentioned in my previous support comment, the LV snippet with category conditional works perfectly fine when displaying the results as HTML - it only encounters encoding issues when the “filename” attribute is also used.
Regards,
Dan
|
|
|
Eli Van Zoeren
|
Posted: 12 January 2016 07:30 PM |
# 5
|
|
Developer
|
Okay, I think I’ve got this sorted out for you. It looks like this is a bug (or at least an unexplained “feature” :) in EE. See https://support.ellislab.com/bugs/detail/20552/snippets-and-early-parsed-vars-appended-by-garbage-when-wrapped-in-plugin. Luckily it is simple to work around. I just uploaded a new version of the plugin that should fix things for you. You will want to go back to Low Variables’ early-parsed (snippet) variant, which I believe is what you started with.
Let me know if that solves it for you!
|
|
|