Announcement

Collapse
No announcement yet.

How do I include TXT files?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    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)
    I went back and re-uploaded the file to the root, then retested. It's working now.

    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>

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    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)

    Leave a comment:


  • lesliekirk
    replied
    Originally posted by Bruce - PhosphorMedia View Post
    Is the file in the root script directory? '/' will tell miva to start from the beginning.
    Yes it is in the root directory (in's not in the data), I am "assuming" that script can also mean public root directory? I did try changing data to script

    Leave a comment:


  • Bruce - PhosphorMedia
    replied
    Is the file in the root script directory? '/' will tell miva to start from the beginning.

    Leave a comment:


  • lesliekirk
    replied
    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>
    And all that showed up on the page was the "There was an error reading the file" message.

    Leave a comment:


  • Brennan
    replied
    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>
    http://docs.miva.com/mivascript/file_read

    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.

    Leave a comment:


  • lesliekirk
    started a topic How do I include TXT files?

    How do I include TXT files?

    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?

Working...
X

This website uses cookies to identify visitors, track visitors to our website, store login session information and to remember your user preferences. By continuing to use this site you agree to our use of cookies. Learn More.

This website uses cookies. By continuing to use this site you agree to our use of cookies. Learn More.

Accept