• Hi!

    First thanks! great plugin help a lot.

    Questions:
    I can’t find a way to display the link in my template file?

    Can I hook/filter into it so it generate an excel with conditional entries?
    Like if value = xxx >> go into the excel…?

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Doeke Norg

    (@doekenorg)

    Hi @davouid, thanks for the question.

    I’m not sure I understand completely, but you want to display the link to download the excel in a template on the front-end?

    Something like this should help with that:

    $form = GFAPI::get_form(3);
    $url = \GFExcel\GFExcel::url($form);

    $url now has the download-link for form 3.

    Please let me know if this helps you out.

    Thread Starter David Corradini

    (@davouid)

    This is exactly what I need, thanks!

    And do you think there is an “easy” way of filtering what goes in the excel?
    I would need to generate different Excel for the same form.
    The thing is I have only one form.
    And multiple custom post of events with an ACF date range that populate a drop down.
    It would be great to be able to download an excel for every event separatly.
    Hope i’m clear.

    My only alternative would be gravityview.

    Thanks again for the plug, i use it on multiple projects.
    Sometime you can find all the complex and bulky plugs, when the only thing you need is something as simple as what you do!

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi David,

    First off, thank you so much for your generous donation; It is greatly appreciated! I love that the plugin has made your life that much easier!

    To answer your question. The results can be heavily influenced by using the filter hooks. You could add some query_string-parameters, and hook in to those with a custom filter.

    Recently I demonstrated how you would go about filtering based on a date. But the idea holds true for this instance as well.

    Take a look a this post: https://www.ads-software.com/support/topic/url-variables/#post-10684492. Hope this helps you out!

    PS, also checkout the caution message below that one. Made a small mistake in the code, but couldn’t edit the post anymore by then ??

    • This reply was modified 6 years, 5 months ago by Doeke Norg. Reason: Adding info about broken code reference
    Thread Starter David Corradini

    (@davouid)

    Thanks both of these worked great.

    My next challenge is the “Chained Selects Add-On” they do not show in the list.

    Is there a way?

    I tried strating from this “I have a custom field. Can your plugin handle this”…
    But i dont even know where to start…

    Plugin Author Doeke Norg

    (@doekenorg)

    Unfortunately I don’t own this add-on, so it’s difficult for me to help you out with that.

    To help you out a bit with the custom Field renderer you could try the following:

    1. Find out what the name of the field type is for this add-on. Not the name of the field, but the TYPE, lets say chained-select
    2. Copy src\Field\AddressField.php to somewhere in your own project, and rename it ChainedSelectField.php
    3. Also rename the class to ChainedSelectField. If you have a namespace, update the namespace at the top. If you don’t just remove it, and require_once the file in your functions.php.
    4. Remove all other functions then getCells.
    5. Do a var_dump of $entry in that function and ‘exit;`.
    6. Add this to your functions.php:

    add_Filter('gfexcel_transformer_fields', function ($fields) {
        $fields['chained-select'] = 'ChainedSelectField'; // or the full namespace if you have it
        return $fields;
    });

    7. Try and download the excel.

    This should show you an array of one entry, and this entry should contains the info you want to show in your field.

    Now it’s up to you to return the wanted value in the getCells function. Place your data in a $value variable, and return it like:
    return $this->wrap([$value]);. Every item in the array is a cell. But if you return multiple cells, make sure to also return multiple columns. You have to update getColumns to do so.

    I hope this is enough for you. If not, send me a copy of the add-on, and I’ll see if I can make it work, in a next release.

    Good luck!

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @davouid,

    As of 1.6.0 we have native support for Chained Select. So you can remove your custom transformer script, and just use the new plugin!

    Have a great day!

    Thread Starter David Corradini

    (@davouid)

    Thanks for the last reply.

    Quick question:

    $form = GFAPI::get_form($form_id);
    $url = \GFExcel\GFExcel::url($form);

    Seems to return

    https://xxx.local/gf-entries-in-excel/

    Any idea?

    Thread Starter David Corradini

    (@davouid)

    Did something like that:

    $url_hash = $form[“gfexcel_hash”];

    And it worked…

    Plugin Author Doeke Norg

    (@doekenorg)

    Hi @davouid,

    Sorry about that. I’ve changed that function a few weeks ago. I only used the form id, so it felt wasteful to give the entire form object.

    $url = GFExcel::url($form_id); should be enough now. Does that work?

    Changed it because it isn’t part of the public API. People aren’t supposed to use that function ??

    Plugin Author Doeke Norg

    (@doekenorg)

    OH, as a side note; I’ve added a shorttag u can use.

    [gfexcel_download_url form=3] should give you the url to form 3.

    [gfexcel_download_url form=3 type=csv] should provide the csv url. Providing xlsx as type will give the excel url. And without it, it will return the default url, which will be what you have chosen as the output in the settings.

    Works for notifcation mails in gravity forms too, but you have to use {gfexcel_download_url} there, as it will figure out it’s own form, and only the default setting applies there.

    Thread Starter David Corradini

    (@davouid)

    Hi!

    Any idea why that does not work?

    <?php echo do_shortcode(‘[gfexcel_download_url form=’. $form_id . ‘]’) ?>

    I get this
    Please add an id argument to ‘gfexcel_download_url’ shorttag

    Plugin Author Doeke Norg

    (@doekenorg)

    Rename form= to id=. Should do the trick. The docs above are incorrect. Sorry about that.

    Thread Starter David Corradini

    (@davouid)

    Indeed it did.

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Display link in template’ is closed to new replies.