Announcement

Collapse
No announcement yet.

How do I include TXT files?

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

  • 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?

    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

  • 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.
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


    • 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.
      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 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
          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 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>
              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

              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