We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40085
    • 7 Posts
    For a site that I am preparing, I wanted to have a repository of quotations to present one of them randomly each time the page is displayed.

    I figured out as I detail below, but I wonder if there is a better method?

    First, I created a container with the options 'Published' unchecked and 'Hide From Menus' checked. In this container, I created some documents of type 'weblink', in which I have filled in the following fields:
    Title:           cite 1   /* cite 2, 3, ... N */
    Long Title:      Albert Einstein
    Description:     1879-1955
    Summary:         I want to know God's thoughts; the rest are details.
    Weblink:         en.wikipedia.org/wiki/Albert_Einstein
    Uses Template:   0        /* empty */
    Resource Alias:  cite-1
    Menu Title:      /* blank */
    Link Attributes: /* blank */

    Then I created a chunk with:
    [[!getResources?
    &parents=`40`        /* the container ID */
    &showHidden=`1`
    &showUnpublished=`1`
    &tpl=`cite`
    &limit=`1`
    &sortby=`RAND()`
    &includeContent=`1`
    ]]

    And the mentioned template:
    <p>"[[+introtext]]"</p>
    <p class="author"><a href="[[+content]]" target="_blank">[[+longtitle]]</a> ([[+description]])</p>


    And what I get is:

    "I want to know God's thoughts; the rest are details."

    Albert Einstein (1879-1955)

    And that's all. Comments?

    Regards,
    Ramon
      • 22303 MODX Staff
      • 10,725 Posts
      Why are you making them Weblinks? This seems better as simply Documents, perhaps with a Template Variable attached which represents the citation/wikipedia link.

      Unless you want them to always link to the citation I suppose, and never have a direct link inside MODX.
        • 3749
        • 24,544 Posts
        FYI, it happens that the example here creates a custom DB table for Revolution to manage quotations: http://bobsguides.com/custom-db-tables.html.

        It might be overkill for you if all you want to do is pull a random quotation. I use it for this: http://wordsmatter.softville.com/quotes.html



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 40085
          • 7 Posts
          Jason and Bob thank you very much for your answers.

          Jason,
          I used 'weblinks' because at that moment I felt better, but will try 'Documents'. And yes, the link is always outside MODx to the relevant page of the author's biography on Wikipedia.

          Bob,
          Thanks for reminding me the link to your always useful guides that have helped me more than once to solve problems, but as you mention yourself too much work [:-)] to randomly select only one of the 40 citations that I added to the site .

          Bob, let me also congratulate you on your wonderful book that I have always at hand when working with MODx, I have repaid every penny I paid for it.

          By the way, have you thought about offering translated versions? I mention this because many of my colleagues (Spanish) that I preach the superb features of MODx, often mention that the biggest problem is the lack of documentation in our language. [ed. note: redesb last edited this post 14 years, 3 months ago.]
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: redesb at Jun 28, 2012, 09:31 AM
            I used 'weblinks' because at that moment I felt better, but will try 'Documents'. And yes, the link is always outside MODx to the relevant page of the author's biography on Wikipedia.
            In that case, WebLinks may indeed be the best choice.