We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19315
    • 84 Posts
    Hi,

    I can quite easily retrieve template variables using $modx->getTemplateVar, but how do I save a new value to a template variable in a snippet? I’ve had a search but I can’t find anything.

    Thanks,

    Michal.
      • 36592
      • 970 Posts
      I think there’s no MODx API to save TVs.

      But you can use Docmanager class or you can make a modification in MODx core.
        • 4749
        • 623 Posts
        michalc,
        What is it that you’re trying to do? There’s more than one way to skin a cat. Maybe if you explain what you’re trying to do there way be an easier, better, or faster way of doing it. So, post what you’re trying to do and be detailed. There are many ’gurus’ here that are more than willing to help when they’re informed. Good luck.

        EDIT: I should have been clearer. Why do you need to retrieve that TV and what are you doing with it? I guess I needed to rephrase the question. Yes, you need to retrieve a TV, but what for and why? A good explanation will go a long way in getting a precise answer. Trust me...I learned from experience.
          The MODx has you...
          Utah Web Design
          • 19315
          • 84 Posts
          Hi,

          Thanks for your responses.

          My aim: Allow front end creation/edit/remove of certain documents, with quite a few custom text-fields (one of which is rich text), and each document has an associated uploaded image (but every document doesn’t have to have an image)

          I’ve set up (a slightly modified) FDM with an (again slightly modified) Fancy Upload snippet to do this, with the custom text-fields all set up as template variables. Upon upload of the image, I wanted the Fancy Upload snippet to set the location of the uploaded file into the correct template variable for the document.

          So far I have found a bit of a workaround: as I only want *one* image associated with each document, I have got Fancy Upload to move the img to [idOfDocument].jpg in a certain location, and I have another short snippet to show the img tag of the only if the file with the correct name exists. However, this is a bit limited and dodgy I think.

          Michal.
            • 7231
            • 4,205 Posts
            This topic discusses uploading files/images via eForm, since FDM uses eForm as a base this might help you as well. Also I seem to recall a discussion on adding images via FDM in the lengthy FDM support forum thread, but I did not bookmark it.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don't know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 36416
              • 589 Posts
              Quote from: dev_cw at Jun 20, 2008, 07:58 AM

              Also I seem to recall a discussion on adding images via FDM in the lengthy FDM support forum thread, but I did not bookmark it.

              Here: http://modxcms.com/forums/index.php/topic,14977.msg147317.html#msg147317
              MODx 0.9.6.2 with Resource Browser enabled for Web Users is required.
              Images are uploaded through TinyMCE dialog "Insert Image/Media".