We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7527
    • 437 Posts
    hi. I have manipulated a snippets php to suit my needs, but I get the following error

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ’)’

    The snippets array for the letters was originally Russian, and I changed them to the English alphabet. It worked fine until I changed the letters.
    Here is my php code

    <?php
    /*
     BuildGlossary_post - this snippet runs Ditto with glossaryFilter in default mode
     Released under the terms of General Public License
     Copyright (c) 2010 Aleksander Maksymiuk, http://setpro.pl/software/ditto-stuff/glossary-extender
    */
    
    # the following array serves for both building the index and validating user's requests
    $allowed_req = array(
        # 'label-for-button-or-link' => 'actual-value-for-regex-clause',
        '0-9' => '0|1|2|3|4|5|6|7|8|9',
        'A' => 'A',
        'B' => 'B',
        'C' => 'C',
        'D' => 'D',
        'E' => 'E',
        'F' => 'F',
        'G' => 'G',
        'H' => 'H'',
        'I' => 'I',
        'J' => 'J',
        'K' => 'K',
        'L' => 'L',
        'M' => 'M',
        'N' => 'N',
        'O' => 'O',
        'P' => 'P',
        'Q' => 'Q',
        'R' => 'R',
        'S' => 'S',
        'T' => 'T',
        'U' => 'U',
        'V' => 'V'',
        'W' => 'W',
        'X' => 'X',
        'Y' => 'Y',
        'Z' => 'Z',
        'ALL' => 'A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z',)
    );
    
    # validate user's request
    $cur_filter = isset($_POST['filter']) && isset($allowed_req[$_POST['filter']]) && $allowed_req[$_POST['filter']] ? $allowed_req[$_POST['filter']] : '';
    
    # build index
    $index = '<form method="post" action="[~[*id*]~]" style="margin: 15px 0 15px 0; padding: 0 20px 0 40px;">';
    foreach ($allowed_req as $label => $request) {
        if ($request) {
            $index .= '<input type="submit" name="filter" value="' . $label . '"' . ($request == $cur_filter ? ' disabled="disabled"' : '') . ' />' . ' ';
        }
    }
    $index .= '<input type="submit" name="clear" value="Clear Listing" />' .
    '</form>';
    
    # generate output
    return $index . ($cur_filter ?
        # valid request encountered - build document listing with extended Ditto (default extender mode)
        '[[Ditto? &parents=`71` &depth=`2` &display=`10` &orderBy=`pagetitle ASC` &sortDir=`ASC` &extenders=`glossaryFilter` &filterBy=`' . $cur_filter . '` &tpl=`Dittosearch` &forceUTF8=`1`]]' :   
     # empty, "clear", or invalid request encountered - do not generate anything
        ''
    );
    ?>


    Can anyone see where the problem is?
      www.PawsForWildlife.co.uk
      www.Borntobrick.co.uk
      • 7527
      • 437 Posts
      Found two issues, a double apostrophe after ’H’ and ’V’. Now I just get a Parse error: syntax error, unexpected ’)’
        www.PawsForWildlife.co.uk
        www.Borntobrick.co.uk
        • 7527
        • 437 Posts
        All fixed. Unexpected bracket after the a|b|c|.....

        Amazing how you can spot errors when the code is in colour!
          www.PawsForWildlife.co.uk
          www.Borntobrick.co.uk
          • 7527
          • 437 Posts
          Well all did work well! The ’ALL’ function doesn’t seem to return all documents within the specified folders. Have I got the layout wrong?
            www.PawsForWildlife.co.uk
            www.Borntobrick.co.uk