Author Topic: Generate a CSV File From A Specific Search?  (Read 7240 times)

0 Members and 1 Guest are viewing this topic.

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Generate a CSV File From A Specific Search?
« on: February 06, 2007, 10:04:21 AM »
Is it possible to generate a CSV file from a speific search on the results page? I would like to show the results of this search and have a download link to just those specific records.

Help me think on this one... It really wouldn't need to be a csv file(but it would be ideal). But have a blank template that would show just the records seperated by pipes or commas then you could in the browser do a file save as that way.

The problem I see is that on the results page I'm not able to duplicate that same search url for the link code going to a different template for just the text/download version. Maybe javascript would be needed to duplicate that same URL. Any ideas on this would be appreciated.
« Last Edit: February 11, 2007, 04:26:17 PM by ADalby »
Uniting Bands
www.unitingbands.com

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: Generate a CSV File From A Speific Search?
« Reply #1 on: February 06, 2007, 10:10:50 AM »
http://www.stylusstudio.com/xsllist/200210/post40170.html#

Wouldn't this be a start for fetching the URL?

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Generate a CSV File From A Speific Search?
« Reply #2 on: February 06, 2007, 10:14:50 AM »
Aaron,

do you need to duplicate the URL that is appearing in the first result template and then append it with something?  Because I do have a js that will do that.  I will have to dust off the archives, but I know I used it on a csvread template before.  I used it to autofilter from the results page, but you could adapt it to do what you want I think.  If that is in fact what you want to do!  haha

Jason
Founder of www.slipdex.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #3 on: February 06, 2007, 10:17:49 AM »
EZ, that is what I'm looking for but couldn't get it to work either. Jason if you can find the script I would love to try it out.
Uniting Bands
www.unitingbands.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #4 on: February 06, 2007, 10:20:02 AM »
Yes, I want to take the current URL of the page I'm on and insert it into a link on that page.
Uniting Bands
www.unitingbands.com

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: Generate a CSV File From A Speific Search?
« Reply #5 on: February 06, 2007, 10:48:46 AM »
Aaron, this works for me:

<script language="javascript">
var strID;
strID = window.document.location.toString();
document.write(strID);
</script>

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Generate a CSV File From A Speific Search?
« Reply #6 on: February 06, 2007, 10:58:12 AM »
I think this will work:

<SCRIPT LANGUAGE="JavaScript">
function append(value) {
document.location.href += "&Field1=" + value;
}
</script>

Then you link will look like this:

<a href="javascript:append('[[field1]]')">

Where [[field1]] is field you want to add on to the existing url.  If it is going to be a static appenditure, then try this:

<SCRIPT LANGUAGE="JavaScript">
function append(value) {
document.location.href +=value;
}
</script>

then the static appenditure will be:

<a href="javascript:append('the actualtext that appends the URL')">

Let me know if that works,
Jason
Founder of www.slipdex.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #7 on: February 06, 2007, 11:22:21 AM »
EZ this javascript is exactly what I'm looking for however it does not fit into a link tag well. Got any ideas on the this. This is how I have it that does not work:


Download:<a href="<script language="javascript">
var strID;
strID = window.document.location.toString();
document.write(strID);
</script>">Here</a>
Uniting Bands
www.unitingbands.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #8 on: February 06, 2007, 11:43:40 AM »
Jason, your script is exactly what I'm looking for because I can append something extra at the end and its in a nice link format already. Thanks again, 2 for 2 today!
Uniting Bands
www.unitingbands.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Generate a CSV File From A Speific Search?
« Reply #9 on: February 06, 2007, 11:44:49 AM »
Aaron try placing the script seperately:

<script>
function linkurl(){
var strID;
strID = window.document.location.toString();
document.write(strID);
</script>

Then in the link call it as:
<a href="javascript:linkurl()"></a>

But again, this will simply rewrite the url, not append anything to it. 

Jason

Jason
Founder of www.slipdex.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #10 on: February 06, 2007, 01:18:07 PM »
Hey Jason, anyway to make this link open in a new window? I have tried the target=_blank or new and the scripts does not pull that url into the new window. Any guesses? Here is what I've got that doesn't work:

Download:
<SCRIPT LANGUAGE="JavaScript">
function append(value) {
document.location.href += "&mytemplate=" + value;
}
</script>
<a href="javascript:append('tp19')" target=_blank>Here</font></a>
Uniting Bands
www.unitingbands.com

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Generate a CSV File From A Speific Search?
« Reply #11 on: February 06, 2007, 01:32:15 PM »
Try this:

<SCRIPT LANGUAGE="JavaScript">
function append(value) {
window.open.href += "&mytemplate=" + value;
}
</script>
Founder of www.slipdex.com

Offline ADalby

  • Hero Member
  • *****
  • Posts: 241
    • Uniting Bands - Where Talents Unite! - Music Promotion, Musician Classifieds
Re: Generate a CSV File From A Speific Search?
« Reply #12 on: February 06, 2007, 01:45:39 PM »
Get a javascript error on that one.
Uniting Bands
www.unitingbands.com

Offline EZ

  • Hero Member
  • *****
  • Posts: 1081
    • Babelnotes.be
Re: Generate a CSV File From A Speific Search?
« Reply #13 on: February 06, 2007, 01:50:07 PM »
The error console of Firefox might help you determine what the error is...

Offline Jason

  • Administrator
  • Hero Member
  • *****
  • Posts: 1018
    • slipdex
Re: Generate a CSV File From A Speific Search?
« Reply #14 on: February 06, 2007, 02:06:37 PM »
I tried the FF firebug, but don't get an error, just no action.  I will have to play with this one a bit later Aaron, the code is starting to run together in my head.  I'll see if I can't figure it out though.

Jason
Founder of www.slipdex.com