We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22770
    • 285 Posts
    So, I’m writing a short snippet that runs through an array of page ids and does a ditto call for each, which I can do no problem. This is what I’m doing:

    foreach ($pageArray as $pageId) {
    $output .= $modx->runSnippet("Ditto",.....);
    }
    

    But what I need to do is put a letter of the alphabet in front of each of the items. So, for example, I would have for the output:

    (A) First ditto result. (B) Second ditto result. (C) Third ditto result.

    Anyone know how I could manage this?

    (I realise that I could, a) make the output an ordered list, display it inline, and use the type attribute to approximate what I want (but the type attribute is deprecated) or b) use an ordered list, display it inline and use CSS to approximate what I want, but I think a PHP solution in the snippet would be far neater.)
      • 10449
      • 956 Posts
      Yes, you could use CSS: http://www.w3schools.com/CSS/tryit.asp?filename=trycss_list-style-type_all
      Nothing wrong with it, imho.
      ul {list-style-type: lower-alpha} or
      ul {list-style-type: upper-alpha}


      With PHP, just define a range:

      $abc = range("A", "Z");
      $pageArray = array("apple","orange","grape","tomato","beef");
      $o = '';
      
      foreach($pageArray as $k=>$v) {
      	$o .= "({$abc[$k]}) $v <br />";
      }
      
      echo $o;
      
        • 22770
        • 285 Posts
        Awesome. Thank you! grin