I have a number of txt files that need to be included in the layout. What would be the "Miva" way to call those files into the layout?
Announcement
Collapse
No announcement yet.
How do I include TXT files?
Collapse
X
-
How do I include TXT files?
Leslie Kirk
Miva Certified Developer
Miva Merchant Specialist since 1997
Previously of Webs Your Way (aka Leslie Nord leslienord)
Email me: [email protected]
www.lesliekirk.com
Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr
Tags: None
-
This example show how to read a CSV file, but you can update this to read any file type:
http://docs.miva.com/template-language/read-csv-file
You only really need to first part:
Code:<mvt:assign name="g.file_read" value="file_read('/credit.csv','data', g.data)" /> <mvt:if expr=" g.file_read NE -1 "> The file was read! File Contents: &mvt:global:data; <mvt:else> There was an error reading the file </mvt:if>
Keep in mind the second parameter is either "data" or "script" depending on if the file you're trying to read is located in the mivadata folder or the public web root.
-
Thanks Brennan. I am obviously doing something wrong. I tried this:Code:<mvt:assign name="g.file_read" value="file_read('/nav2.txt','data', g.data)" /> <mvt:if expr=" g.file_read NE -1 "> The file was read! File Contents: &mvt:global:data; <mvt:else> There was an error reading the file </mvt:if>
Leslie Kirk
Miva Certified Developer
Miva Merchant Specialist since 1997
Previously of Webs Your Way (aka Leslie Nord leslienord)
Email me: [email protected]
www.lesliekirk.com
Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr
Comment
-
Is the file in the root script directory? '/' will tell miva to start from the beginning.
Bruce Golub
Phosphor Media - "Your Success is our Business"
Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
phosphormedia.com
Comment
-
Originally posted by Bruce - PhosphorMedia View PostIs the file in the root script directory? '/' will tell miva to start from the beginning.
Leslie Kirk
Miva Certified Developer
Miva Merchant Specialist since 1997
Previously of Webs Your Way (aka Leslie Nord leslienord)
Email me: [email protected]
www.lesliekirk.com
Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr
Comment
-
hmmm...the only time I see this problem is when I don't actually get the path/filename. (Btw. I didn't read the last post...you had 'data' so it should be in /mivadata directory not the root)Bruce Golub
Phosphor Media - "Your Success is our Business"
Improve Your Customer Service | Get MORE Customers | Edit CSS/Javascript/HTML Easily | Make Your Site Faster | Get Indexed by Google | Free Modules | Follow Us on Facebook
phosphormedia.com
Comment
-
Originally posted by Bruce - PhosphorMedia View Posthmmm...the only time I see this problem is when I don't actually get the path/filename. (Btw. I didn't read the last post...you had 'data' so it should be in /mivadata directory not the root)
Just to clarify, here is the code that is in place:
Code:<mvt:assign name="g.file_read" value="file_read('/nav2.txt','script', g.script)" /> <mvt:if expr=" g.file_read NE -1 "> The file was read! File Contents: &mvt:global:script; <mvt:else> There was an error reading the file </mvt:if>
Leslie Kirk
Miva Certified Developer
Miva Merchant Specialist since 1997
Previously of Webs Your Way (aka Leslie Nord leslienord)
Email me: [email protected]
www.lesliekirk.com
Follow me: Twitter | Facebook | FourSquare | Pinterest | Flickr
- 1 like
Comment
Comment