We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23044
    • 20 Posts
    Does Ditto provide a equivalent to NewsPublisher? I can’t find anything in the docs about how to post from the web instead of logging in to the manager.

    Thanks
      • 25663 MODX Staff
      • 12,272 Posts
      You would still need NewsPublisher for that.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 23044
        • 20 Posts
        So I can use NewsPublisher with Ditto? Would I just use the documentaion for NewsListing?
          • 25663 MODX Staff
          • 12,272 Posts
          NewsPublisher has nothing to do with NewsListing. One is for creating, one is for showing. Ditto replaced Newslisting.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 23044
            • 20 Posts
            Thanks. I’ll go read the docs on NewsPublisher.
              • 5290
              • 29 Posts
              In trying to format the archive through the use of CSS I bumped into the age old problem of identifying the first/last item/category in the list, so I decided to resolve this. Unfortunately, the way in which the archive is build in Ditto does not allow for identifying the last item, but that’s allright since most of the time, telling either the first or last item apart from the rest will suffice.

              The function generateArchive( ), which can be found in assets/snippets/ditto/ditto.class.inc.php, should be replaced with the code below. (Modifications marked with comments).
              	function generateArchive($archiveText, $archivePlaceholder, $stop, $total, &$resource, $dateFormatType, $dateFormat, $archiveDateType, $templates, $debug) {
              		global $modx;
              		$lastCategory = "";
              		$archivehtml = "";
              		$archiveHTML .= "<h3>$archiveText</h3><div id=\"ditto_archivelist\"><ul>";
              
              		for ($i = $stop; $i < $total; $i++) {
              			$dateArray = getdate($resource[$i][$dateFormatType]);
              			$category = strftime("%B %Y", $resource[$i][$dateFormatType]);
              			$subCategory = $dateArray['mon'];
              			if ($subCategory != $lastCategory) {
              				if ($lastCategory != "") {
              					$archiveHTML .= '</ul></li>';
              				}
              				// MODIFICATION from original Ditto 1.0.2
              				if ($i == $stop) { $archiveHTML .= '<li class="ditto_category ditto_firstcategory"><span class="ditto_month">' . $category . '</span><ul>'; }
              				else { $archiveHTML .= '<li class="ditto_category"><span class="ditto_month">' . $category . '</span><ul>'; }
              				$archiveHTML .= "<li class=\"ditto_archpost ditto_firstarchpost\" title=\"$lastCategory\" id=\"$subCategory\">";
              			}
              			// MODIFICATION from original Ditto 1.0.2
              			else {
              				$archiveHTML .= "<li class=\"ditto_archpost\" title=\"$lastCategory\" id=\"$subCategory\">";
              			}
              			$archiveHTML .= $this->render($resource[$i], 0, "archive", $archiveDateType, $templates, $dateFormat, $debug, "", "", $stop);
              			$archiveHTML .= "</li>";
              			$lastCategory = $subCategory;
              
              		}
              		$archiveHTML .= "</ul></li></ul></div>";
              
              		if ($archivePlaceholder == 1) {
              			$modx->setPlaceholder('archive', $archiveHTML);
              		} else {
              			return $archiveHTML;
              		}
              	}
              


              This will return the following HTML:
              <ul>
              	<li class="ditto_category ditto_firstcategory"> ...
              		<ul>
              			<li> class="ditto_archpost ditto_firstarchpost"> ... </li>
              			<li> class="ditto_archpost"> ... </li>
              		</ul>
              	</li>
              	<li class="ditto_category"> ...
              		<ul>
              			<li> class="ditto_archpost ditto_firstarchpost"> ... </li>
              			<li> class="ditto_archpost"> ... </li>
              		</ul>
              	</li>
              	...
              </ul>
              

              I feel that adding a second classsname works better than replacing the original one, since it relieves you of the obligation to define the ’ditto_first...’ classes whenever you don’t use them. This way, if you do intend to use them, just define them last and everything will work as intended.
                A computer program is a utilitarian typographer's dream - a functioning machine composed completely of type. (John Maeda)
                • 28122
                • 51 Posts
                Am I correctly assuming that
                &descendentDepth=`0`
                should only display the immediate children of the document that is calling Ditto? After realizing that I had spelled it as descendant, I thought my issue was licked...sadly, the grandchildren are still showing up in the output. (Just for the record, the spelling nazi in me still says it’s spelled with an A!) smiley
                Here’s the entire call:
                [[Ditto?startID=`40`&tpl=`Listing`&showarch=`false`&summarize=`10`&descendentDepth=`0`]]
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I would suspect that 1 would be the correct value here. 0 may just make it act as if it were unlimited.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 28122
                    • 51 Posts
                    And so it does.
                    Many thanks!
                      • 28338
                      • 46 Posts
                      How could I get Ditto to display the latest post in its entirety and then a summary of a couple of posts? Like this:

                      Post ’n’ (Complete)

                      Post ’n-1’ (Summary)

                      Post ’n-2’ (Summary)

                      Post ’n-3’ (Summary)

                      This discussion is closed to further replies. Keep calm and carry on.