We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11807
    • 21 Posts
    ...I use Ditto to publish News on my site... there is a way to link files directly?
    For example, if i want open a pdf file when the user click on the title of the news, how I can do it?
    Using sendRedirect(’FILENAME’) huh
      • 17883
      • 1,039 Posts
      1. Create a template variable type "file", for example with the name "news-pdf", fill out the TV with the PDF for any document (news)
      2. Use your ditto template like this for the headline:

      <h1><a href="[+tvnews-pdf+]" title="[+pagetitle+]>[+pagetitle+]</a></h1>


      Should work, but not tested.
        • 11807
        • 21 Posts
        Some news only are links to pdf file, so i try this way:

        - I create a TV named "news-pdf"
        - in the singles pages that will be "links" to pdf files I set the value of TV "news-pdf"
        - in this pages i call a snippet with this code

        <?php
        $modx->sendRedirect($modx->documentObject[’news-pdf’]);
        ?>

        ...the problem is this: documentObject[’news-pdf’] return "array" as value... why?

        thanks MadeMyDay
          • 18397
          • 3,250 Posts
          If you are saying only some news entries should link to a pdf, just make the default value of the tv [~[+id+]~] that way it will link to the full news entry if it is not a PDF.
            • 11807
            • 21 Posts
            Sorry grin, I have solved the problem creating a custom Ditto template (with +description+ and no +summary+) and set the pdf link pages as weblink.