We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8454
    • 55 Posts
    Hi!
    I have a Ditto ouput filter in a custom Ditto config file.
    <?php
    $filter='matchingTVvalue,' . $_GET['frompage'] . ',7';
    ?>
    The filter is used for a menu where matchingTVvalue must match the ’frompage’ value which is passed via the URL when coming to the menu page. This works great when clicking a link I have rigged to get to the page containing the menu. If, however, I come to the page from somewhere else, i.e. from a search, no value ’frompage’ is being passed and of course I get a parse error: Empty delimiter
    I would like to set a default ’frompage’ value in those cases, but with limited php knowledge can’t get the syntax right:
    <?php
    $filter='matchingTVvalue,' . if (isset($frompage)) {
    	 $_GET['frompage'];
    } else {
    	$frompage = 56;
    }
     $_GET['frompage']; . ',7';
    ?>
    Sorry for this lousy coding...
    (Ditto 2.1, modx 0.9.6.3 on MAMP)
      • 4310
      • 2,310 Posts
      Untested, and I’m not familiar with the Ditto config approach but you could try something like :
      <?php
      $value = $_GET['frompage'];
      if(empty($value)){
      $value = 56;
      }
      $filter='matchingTVvalue,'.$value.',7';
      ?>
        • 8454
        • 55 Posts
        Thanks David, that did the trick!
          • 4310
          • 2,310 Posts
          That’s good, never sure without testing first  wink