• Resolved michael3740

    (@michael3740)


    Hi Peter, Question 2
    I have 3 fields in my table with hyperlinks.

    • Screenshot of Response is a Dynamic Hyperlink pointing to an image file on my site.
    • Zipfile is set as a hyperlink in Data Explorer and has the format
      {"label":" Download: foi-202100216108.zip", "url":"https://thetrue.scot/wp-content/include-me/foi/zip/foi-202100216108.zip","target":"_blank"}
    • docLinks is in the format of standard HTML

    All three work fine when viewed on the screen but in exports all I get is the link text, e’g’ Download: foi-202100216108.zip rather than the actual URL.

    The third question is kind of related to the above in that I’m wondering if it is possible to export different fields than are displayed? If it was then I’m guessing that a field that is set to text but contains a valid URL would export the URL intact?

    Thanks again

    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Michael,

    Your hyperlink question is a tough one! The standard export buttons just export the content. What do you want to be exported?

    You can add your own custom buttons and add your own logic. This is documented here:
    https://wpdataaccess.com/docs/documentation/data-publisher/custom-buttons/

    Below is the code for the SQL button (part of the premium version). You could write something similar that fits your needs.

    function export_publication_selection_to_sql(table_name, pub_id, wp_nonce, primary_key) {
    	// Get table data
    	table = jQuery('#' + table_name + pub_id ).DataTable();
    	rows = table.rows({selected:true});
    	if (table.rows({selected:true}).count()===0) {
    		rows = table.rows();
    	}
    	data = rows.data();
    
    	// Add key values to array
    	ids = [];
    	rows.every(function ( rowIdx, tableLoop, rowLoop ) {
    		ids.push(jQuery(this.node()).find('td').eq(jQuery(this.node()).find("td." + primary_key).prop("cellIndex")).text());
    	});
    
    	// Define target url and add arguments
    	url =
    		wpda_pluginvars.wpda_ajaxurl +
    		"?action=wpda_export&type=row&mysql_set=off&show_create=off&show_comments=off&format_type=sql" +
    		"&pub_id=" + pub_id +
    		"&table_names=" + table_name +
    		"&_wpnonce=" + wp_nonce;
    
    	// Add keys to url
    	for (i=0; i<ids.length; i++) {
    		for (var pk in primary_key) {
    			url += '&' + primary_key[pk] + '[' + i + ']=' + encodeURIComponent(ids[i]);
    		}
    	}
    
    	window.location.href = url;
    }

    Thanks,
    Peter

    Thread Starter michael3740

    (@michael3740)

    Thanks Peter

    I don’t know enough to code that but I’ll see what I can learn.

    For the links, a standard link is
    <a href="https://www.example.com">Link Text</a>
    The export functions will output Link Text but I want to be able to output https://www.example.com

    I’m thinking of a few workarounds and will update this thread for others to maybe benefit from in the future.

    Michael

    • This reply was modified 3 years, 6 months ago by michael3740.
    • This reply was modified 3 years, 6 months ago by michael3740.
    Plugin Author Passionate Programmer Peter

    (@peterschulznl)

    Hi Michael,

    Is it be an option to show the link + the full URL? The user can still click on the link in the browser but the full link will be printed as well. You could use a dyanmic hyperlink to achieve that result (need to change the format of the column as well). See:
    https://wpdataaccess.com/docs/documentation/data-explorer/dynamic-hyperlinks/

    Best regards,
    Peter

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Data Export – hyperlinks’ is closed to new replies.