We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30884
    • 142 Posts
    I’ve got a set of articles all on the one folder. On our front page I want to display one as a main article (With large image), two as smaller (with smaller images) articles and then 6-9 others as simple text headlines. I’ve got a rating system which is sorting by a date in a TV (project date not article date) which works fine when it’s all in one ditto call, but the front page has 3 different ditto calls.

    Right now I’ve got it working but I’m using 3 separate ditto calls and there is some duplication on the top article and the sub articles, then the text news. I know I can tell Ditto to assign a tpl for the 1st and last articles, but can I hack the ditto code to change it to the first, second and third articles?

    I’m having a look into it now but wanted to see if there was anyone who’s managed to achieve this.

    Cheers

    TXRX



    Update: Manged to add additonal tpl statements and options into the core code. See below posting.
      p i x e l p u s h e r e x t r o d i n a i r e
      A x i s A n i m a t i o n . c o m
      • 30884
      • 142 Posts
      (edit ditto file located here: \assets\snippets\ditto\classes\)
      updated the template.class.inc.php from line 163 onwards with:

      	// ---------------------------------------------------
      	// Determine current template
      	// ---------------------------------------------------
      	function getCurrentTPL($x, $stop, $id, $format, $templates) {
      		global $modx;
      		// determine current template
      		$currentTPL = "tpl";
      		if ($format == "archive") {
      			$currentTPL = "tplArch";
      		} else if ($format == "html") {
      			if ($x % 4) {
      				$currentTPL = "tplAltRows";
      			}
      			if ($x == 0) {
      				$currentTPL = "tplFirstRow";
      			}
      			if ($x == 1) {
      				$currentTPL = "tplSecondRow";
      			}
      			if ($x == 2) {
      				$currentTPL = "tplThirdRow";
      			}
      			if ($x == $stop -1) {
      				$currentTPL = ($x % 2 && $templates["tplLastRow"] == $templates["tpl"]) ? "tplAltRows" : "tplLastRow";
      			}
      			if ($id == $modx->documentObject['id']) {
      				$currentTPL = "tplCurrentDocument";
      			}
      		}
      	return $currentTPL;
      	}


      Then altered the ditto 2.02 snippet code to look like this:
      $templates = array(
      	"default" => "@CODE".$_lang['default_template'],
      	"base" => $tpl,
      	"alt" => $tplAlt,
      	"first" => $tplFirst,
      	"second" => $tplSecond,
      	"third" => $tplThird,
      	"last" => $tplLast,
      	"current" => $tplCurrentDocument
      );


      by adding these two lines:
      	"second" => $tplSecond,
      	"third" => $tplThird,
      



      New command line options are obviously &tplSecond and &tplThird all works a-ok here. comments or problems most welcome.
      Cheers

      TXRX
        p i x e l p u s h e r e x t r o d i n a i r e
        A x i s A n i m a t i o n . c o m
        • 29544
        • 1 Posts
        TXRX,

        I am going to have something like this, i mean something that you called them as additional &tpl, thats making sense to me when i read the lines but that doesn’t seem to do the same with ditto!?

        Parse error: parse error, unexpected ’=’, expecting ’)’ in C:\wamp\www\modx-0.9.6\manager\includes\document.parser.class.inc.php(766) : eval()’d code on line 709

        i am getting the error after following the steps you mentioned and im using modxhost template by default installation of modx

        I’m having difficult time to understand what to do after the steps you have mentined?

        I intended to make kinda medium size news website(blog like), i know how to have users to update the news and am planing to design something like this template but with another vertical coloumn to list different news categories ie: -Sports, -Arts, -Entertainment, etc...

        Kinda new to Modx but have read documentation about ditto, news publisher, news listing, yet those are just adding more heat to my head ! i couldnt configure what to do next to have the things in its right place and how to call ditto in documents?

        please help me with some tip on how to get this done from the begining, i mean from the default installation of modx, please write some step by step with a little description about what they do exactly,... no need to mention how to access resources or manager or something like that but please let me know of the reason of using some code at somewhere in modx, this way ill learn faster.

        Sorry if i had said much but am really helpless stuck now :’(
        Thanks for your time and replies kiss

        May.
          • 30884
          • 142 Posts
          I had left out a > on one of the lines
          it should be:
          "second" => $tplSecond,
          "third" => $tplThird,

          not
          "second" => $tplSecond,
          "third" = $tplThird,

          as I had posted. Corrected the error. Try that and see if this works now. Soz.
            p i x e l p u s h e r e x t r o d i n a i r e
            A x i s A n i m a t i o n . c o m
            • 29548
            • 2 Posts
            Thanks, I have corrected the line as you said and now i get this error whn i point to index!

            Fatal error: Call to undefined method template::determine() in C:\wamp\www\modx-0.9.6\manager\includes\document.parser.class.inc.php(766) : eval()’d code on line 936


              • 29548
              • 2 Posts
              When i browse the other pages, i get a blank page with source of:

              <?
              // Use the following syntax $param = ’value’;
              ?>

              any idea to bypass this?
              Thanks.
                • 30884
                • 142 Posts
                I should point out that I’m using Mod x0.95. That may be a problem I suspect. Anyone able to advise as to what can be calling this error up?
                  p i x e l p u s h e r e x t r o d i n a i r e
                  A x i s A n i m a t i o n . c o m