We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34017
    • 898 Posts
    manu,

    i think a modal would be appropriate for dropdowns, etc. but definitely start simple.

    Jason,

    How would I retrieve the placeholders in a page?
    would I use something like $tags = $parser->collectElementTags();

    the basic question would be: how to wrap each element with some tag.
      Chuck the Trukk
      ProWebscape.com :: Nashville-WebDesign.com
      - - - - - - - -
      What are TV's? Here's some info below.
      http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
      http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: ChuckTrukk at Feb 02, 2009, 11:25 AM

      How would I retrieve the placeholders in a page?
      would I use something like $tags = $parser->collectElementTags();
      Yes, basically using the process the current QuickEdit uses, which is the OnParseDocument event. This event in Revolution (unlike 0.9.x) executes as each level of tags are processed.

      The new parser is a special "service" object of modX, and once loaded, is available as $modx->parser. Then you can use collectElementTags to grab all the tags in the content (note it will return the number of tags found, not including nested tags) and do what you need to with them:
      <?php
      /* create arrays to hold your tags and your replacement targets */
      $tags = array();
      $targets = array();
      
      /* collect the tags found in $modx->documentOutput into your tag array */
      $tagCount = $modx->parser->collectElementTags($modx->documentOutput, $tags);
      
      if ($tagCount) {
          /* you could just add logic to replace the tags then with your controls
              by setting a property for the plugin that contains a prefix and suffix template */
          foreach ($tags as $tag) {
              /* TODO: here you can inspect the tag and determine if it should be replaced */
              $targets[$tag[0]] = $prefix . $tag[0] . $suffix;
          }
      
          if (!empty($targets) $modx->parser->mergeTagOutput($targets, $modx->documentOutput);
      }
      ?>


      Be aware this needs to be as efficient as possible, as this event executes every time a piece of content is parsed for tags, including tags that are nested in other tags, and when processed tags return additional tags. On average this will be executed 10 to 20x more frequently than QuickEdit did in 0.9.x.

      Also, you will NEVER want the page to be cached when rendered with QuickEdit controls! A switch statement in the above plugin to listen for the calling event and simply disable caching for that view would work, e.g.
      <?php
      switch ($modx->event->name) {
          case 'OnParseDocument':
              /* put code from above here */
              break;
          case 'OnWebPagePrerender':
              $modx->config['cache_resource'] = false;
              break;
      }
      ?>
        • 3749
        • 24,544 Posts
        wrap each item with some syntax <!-- editable docid: 45 placeholder: content --> html <!-- end editable --> (something like this)

        That reminds me a little too much of Dreamweaver. wink

        Luckily, don’t think it will be necessary.
          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
          • 34017
          • 898 Posts
          so we’d basically do:

          <?php
          if (user can edit this page && user is in edit mode)
          {
             OnParseDocument->
                loop through and surround the areas with something (like a div)
             OnWebPagePrerender->
                $modx->config['cache_resource'] = false;
          }
          //pseudo code. php tags for highlighting
          ?>
          


          Anyone, what would be the best way to define the div attributes for the inline edit?
          we could do like shadowbox and wrap the element with

          <div class="inline-edit" resourceType="(chunk|pageResource)" docid="doc id here">
          content here
          </div>

          Since this is only seen by admins, valid css attr shouldnt matter. The site loads normal for visitors and admins not in edit mode. What say you?

          BTW - thanks jason for pointing out how the new api is working.
            Chuck the Trukk
            ProWebscape.com :: Nashville-WebDesign.com
            - - - - - - - -
            What are TV's? Here's some info below.
            http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
            http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008