К содержанию

Line break or new line in snippet template?

Hello, maybe it is a strange question, but is there a way to make:

&tpl=`@INLINE <li[[+classes]]><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>`

display in html not in one line
<li></li><li></li><li></li>
but in new lines:
<li></li>
<li></li>
?

Thanks!
Trying
Trying
07 марта 2016, 16:07
modx.pro
4 435
Реклама

Комментарии: 9

Василий Наумкин
Василий Наумкин Администратор
07 марта 2016, 20:14
1. Why you need this?

2. Did you try to?
&tpl=`@INLINE <li[[+classes]]><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>\n`
    Trying
    Trying Старожил
    07 марта 2016, 21:03
    Yes, I did. It displays \n in html. For whatever reason, when all
    <li></li><li></li>
    are in one line sometimes occur slight distortions of css styling. In Wayfinder every rowtpl is in new line, I found in wayfinder.class.php this line:
    /* return the row */
            $separator = $this->modx->getOption('nl',$this->_config,"\n");
            return $output . $separator;
    Probably it is possible to add somewhere \n in pdomenu.class.php?
      Василий Наумкин
      Василий Наумкин Администратор
      08 марта 2016, 06:46
      Probably it is possible to add somewhere \n in pdomenu.class.php?
      Again, why?
    Алексей
    Алексей Проверенный
    08 марта 2016, 09:31
    You can use
    &outputSeparator Optional line for separation of the results
    That behavior is describe in official documentation in this page:
    docs.modx.pro/en/components/pdotools/general-settings#Template-parameters
    like:
    &tpl=`@INLINE <li[[+classes]]><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>`
    &outputSeparator=` `
    It necessary set it to «one space» symbol:
    &outputSeparator=` `
    , because if use simply empty string,
    &outputSeparator=``
    it not properly work.

    By default it set to
    &outputSeparator=`\n`
    according to this code: github.com/bezumkin/pdoTools/blob/master/core/components/pdotools/model/pdotools/pdotools.class.php#L63
    Trying
    Trying Старожил
    09 марта 2016, 12:42
    Ok, so looking at how it was implemented in Wayfinder, I have just changed this line in pdomenu.class:

    return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
    to this bit of code:
    $tploutput = $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
    $newline = "\n";
    return $tploutput . $newline;
    Ant it works. Probably it is possible to make it more elegant and simple, but since I know nothing in these things so can only mimic what is done elsewhere.

      Trying
      Trying Старожил
      09 марта 2016, 13:39
      And this also works:
      return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']) . "\n";
      Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
      9