Line break or new line in snippet template?
Hello, maybe it is a strange question, but is there a way to make:
display in html not in one line
Thanks!
&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!
Комментарии: 9
1. Why you need this?
2. Did you try to?
2. Did you try to?
&tpl=`@INLINE <li[[+classes]]><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>\n`
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? Probably it is possible to add somewhere \n in pdomenu.class.php?Again, why?
You can use
docs.modx.pro/en/components/pdotools/general-settings#Template-parameters
like:
By default it set to
&outputSeparator Optional line for separation of the resultsThat 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
No, it doesn't work. Does nothing. Also can't find setting outputSeparator being referenced in other class.php files
it use in every snippet from «pdoTools» package, because it get data from mysql Data Base by dint of class pdoFetch. In class pdoFetch it setting place this: github.com/bezumkin/pdoTools/blob/master/core/components/pdotools/model/pdotools/pdofetch.class.php#L163
Nope.
pdoMenu has its own class that extends pdoFetch. Menu generation is complicate so it has its own logic, without &outputSeparator.
pdoMenu has its own class that extends pdoFetch. Menu generation is complicate so it has its own logic, without &outputSeparator.
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.
And this also works:
return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']) . "\n";
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.