We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10487 MODX Staff
    • 1,535 Posts
    Hi all,

    Here’s a quick snippet that I wrote for my site, I thought it might be useful to someone so decided to post it here. smiley

    The snippet allows for a simple A to Z listing to be displayed for site, filtered by a letter of the alphabet.

    It outputs to two placeholder values, [+atozletters+] and [+atozresults+].

    To run, you need to include the snippet on the page, and then use the placeholders above to display the letter selection and results on the page (you can use a chunk to display the output in a particular format)

    Demo URL: http://www.immerse.me.uk/A-to-Z.html

    Version 6 offers the ability to have multiple startid’s and an extra ’letter’ of the alphabet has been added so titles that start with a non-alphabet character can be listed.

    The snippet does not display documents that have been deleted, are unpublished, or that have private web permissions assigned to them.


    Snippet Variables

    These are some snippet variables that can be used to customise the output of the snippet:


    • &title: This relates to a column in the site_content table and will be displayed as the main hyperlink to the page. Examples are: pagetitle, longtitle.
    • &norecords: The message to be displayed when no records are returned for a particular letter.
    • &intro: The message that will be displayed when the page is first opened (ie. no letter has been selected)
    • &summary: Optional second column from the site_content table to display, for example, introtext. Ideal for displaying a short description of the page.
    • &startid: Optional id of a start folder (can be comma separated to include multiple start ids), useful if you wish to only list the contents of a particular folder(s).
    • &hidemenu: Optional boolean value (true or false) that sets if the listing will not display documents that have ’Hide in Menu’ set. (Default: honours Hide in Menu option)

    CSS Styling

    The following CSS classes can be used to style the output:


    • azalpha: This styles the letters of the alphabet.
    • azsep: This styles the separator between the letters of the alphabet.
    • azlist: The style applied to the top <ul> in the results placeholder.


    Example Snippet Call

    [!atoz? &intro=`Please choose a letter from the above selection` &norecords=`Sorry, no pages have been found for this page` &summary=`longtitle` &startid=`2,24` &hidemenu=false!]



    Let me know what you think, it’s only a basic snippet but I’ll be happy to expand it if there’s enough interest.

    Cheers, Garry

    (version 5: 126 downloads)
      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 7455
      • 2,204 Posts
      Nice work is there also a option ALL (like sitemap would do?)?
        follow me on twitter: @dimmy01
        • 10487 MODX Staff
        • 1,535 Posts
        Thanks, Dimmy.

        Not yet, but sure I could get one in there. I’ll try and get it added in now.

        Cheers, Garry

          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 6726
          • 7,075 Posts
          Thanks Garyn ! It will most definitely be an helpful snippet smiley I have been tweaking newslisting to have it do this but this will be cleaner...

          I’ll test and report !
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 10487 MODX Staff
            • 1,535 Posts
            Thanks David. grin

            Like I say it was primarily for my site so it would great to get everybody’s feedback.

            It’s now been updated to have the display ’ALL’ option and fixed a bug to ensure it doesn’t display the unpublished documents.

            Cheers, Garry
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 6726
              • 7,075 Posts
              Cool, I’ll make sure to download the latest...

              I have just read the snippet, two questions come to mind :

              • could it be made to have a &startID parameter to list only documents in a given folder ?
              • also, could it return TVs and not only site_content table fields ? Forget it, I have been a little ahead of myself here... never mind.

              Thanks !
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 10487 MODX Staff
                • 1,535 Posts
                Hi David,

                I’m pretty sure it could, it’s about at the edge of my knowledge at the moment but if somebody could give me a few pointers I’ll definitely have a go.

                Thanks for the suggestions, Garry
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 10487 MODX Staff
                  • 1,535 Posts
                  Hi all,

                  I have posted a new update to the snippet, in the first post of this thread: http://modxcms.com/forums/index.php/topic,2764.msg19354.html#msg19354

                  It adds the ability to specify a start folder for the A-Z listing as mentioned by David. Also, you can now set whether it should display or not display documents that have the ’Hide in Menu’ option selected.

                  Cheers, Garry
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 6726
                    • 7,075 Posts
                    Waow this was fast !

                    Thanks a lot I’ll try this as soon as I get the chance smiley
                      .: COO - Commerce Guys - Community Driven Innovation :.


                      MODx est l&#39;outil id
                      • 8461
                      • 205 Posts
                      hi garry,

                      I was getting a parser error when I used startID=1 (which was wrong startID in any event),

                      « MODx Parse Error »
                      MODx encountered the following error while attempting to parse the requested resource:
                      « PHP Parse Error »
                       
                      PHP error debug
                        Error: 	Invalid argument supplied for foreach()	 
                        Error type/ Nr.: 	Warning - 2	 
                        File: 	/home/sites/ivolt.co.uk/public_html/wordsworth/manager/includes/document.parser.class.inc.php(691) : eval()'d code	 
                        Line: 	90	 
                       
                      Parser timing
                        MySQL: 	0.0133 s s	(24 Requests)
                        PHP: 	0.0733 s s	 
                        Total: 	0.0867 s s


                      Having corrected my StartID to 0 from 1 (which was the home page, two things happended. The alphabet now wraps correctly whereas previously it stayed full width and broke out of the content section. Now no parser error is displayed but I cannot get any results to display, just blank page below the alphabet letters.

                      This is my call on the page. The snippet itself is an exact copy with no modifications. I am assuming I don’t need to do anything else. I have CSS rules, which I have matched to your site for testing. I have no seperate

                      [!atoz? &intro=`Please choose a letter from the above selection` &norecords=`Sorry, no pages have been found for this page` &summary=`longtitle` &startid=`0` &hidemenu=false!]
                      
                      [+atozletters+] 
                      
                      [+atoztresults+]


                      Am I OK to add the [+atozletters+] directly to the page content