P
P
pzru2015-12-03 18:59:18
MODX
pzru, 2015-12-03 18:59:18

[[!If? does not output chunks. Or is the problem deeper? How to fix?

Hello. Please tell me what I'm doing wrong:
There is a chunk:

[[!If?
   		&subject=`[[!smrProfileUserEditStatus]]`
   		&operator=`inarray`
   		&operand=`2,3`
   		&then=`[[$smrProfileRequestUserEditDisabled]]`
   		&else=`[[$smrProfileRequestUserEditEnabled]]`
   	]]

Snippet [[!smrProfileUserEditStatus]], returns 1,2,3 or empty. Checked, it works. Just in case, snippet code:
$reqid = $_GET['cpreq'];
$pst = "";
$output = "";
if (is_numeric($reqid)) {
  $pst = $modx->getObject('VinZapros', array('id' => $reqid));
  $output = $pst->get('prstatus');
}
return $output;

There are two chunks, the ones in the &then and &else chunks at the beginning of the post. If they are simply displayed on the page, without the [[!If?]] condition in the chunk, then they are perfectly displayed and displayed, they work. If you call them in [[!If?]] , then it returns an empty page.
in error.log throws errors:
[2015-12-03 18:29:40] (ERROR @ /index.php) `[id]~` is not a valid integer and may not be passed to makeUrl()

It crashes when I try to enter the page with the chunk at the beginning of the post..
If I display the chunk itself, the one in else or then ([[$smrProfileRequestUserEditDisabled]] or [[$smrProfileRequestUserEditDisabled]]), independently without if, they are displayed , snippets and forms work in them, etc., but the errors on this page pour into the log are still the same.
If run in the Console $modx->getChunk('smrProfileRequestUserEditEnabled'); , or $modx->getChunk('smrProfileRequestUserEditDisabled'); or the one at the beginning of the post, it gives a more detailed error log, already with warnings:
[2015-12-03 18:51:55] (WARN @ /manager/components/console/connectors/console.php)
`27` was requested but no alias was located.
[2015-12-03 18:51:55] (WARN @ /manager/components/console/connectors/console.php)
`17` was requested but no alias was located.
[2015-12-03 18:51:55] (ERROR @ /manager/components/console/connectors/console.php)
`[id]~` is not a valid integer and may not be passed to makeUrl()
[2015-12-03 18:51:55] (WARN @ /manager/components/console/connectors/console.php)
`19` was requested but no alias was located.
[2015-12-03 18:51:55] (WARN @ /manager/components/console/connectors/console.php)
`17` was requested but no alias was located.
[2015-12-03 18:51:56] (WARN @ /manager/components/console/connectors/console.php)
`27` was requested but no alias was located.

Comrades, tell me what to do? plz :(

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
P
pzru, 2015-12-03
@pzru

I decided. Fixed links. The errors are gone, but the problem remains. Went by elimination method. And it turned out that inside the [[$smrProfileRequestUserEditEnabled]] and [[$smrProfileRequestUserEditDisabled]] chunks, the [[$smrUserProfileTop]] chunk was called, in which the [[!smrProfileMenu]] snippet was called , containing:

<?php
$idcd = $modx->resource->get('id');
if ($idcd == 27) {
  echo "
  <li class=\"mrt0\"><a class=\"side\" style=\"border-right: 5px solid #e7e7e7;\" href=\"".$modx->makeUrl(27)."\"><i class=\"fa fa-list-alt mrr15\"></i>Мои заявки</a></li>
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(17)."\"><i class=\"fa fa-list mrr15\"></i>Мои заказы</a></li>
    <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(19)."\"><i class=\"fa fa-user mrr15\"></i>Личные данные</a></li>";
}
else if ($idcd == 17) {
  echo "
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(27)."\"><i class=\"fa fa-list-alt mrr15\"></i>Мои заявки</a></li>
  <li class=\"mrt0\"><a class=\"side\" style=\"border-right: 5px solid #e7e7e7;\" href=\"".$modx->makeUrl(17)."\"><i class=\"fa fa-list mrr15\"></i>Мои заказы</a></li>
    <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(19)."\"><i class=\"fa fa-user mrr15\"></i>Личные данные</a></li>";
}
else if ($idcd == 19) {
  echo "
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(27)."\"><i class=\"fa fa-list-alt mrr15\"></i>Мои заявки</a></li>
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(17)."\"><i class=\"fa fa-list mrr15\"></i>Мои заказы</a></li>
    <li class=\"mrt0\"><a class=\"side\" style=\"border-right: 5px solid #e7e7e7;\" href=\"".$modx->makeUrl(19)."\"><i class=\"fa fa-user mrr15\"></i>Личные данные</a></li>";
}
else {
  echo "
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(27)."\"><i class=\"fa fa-list-alt mrr15\"></i>Мои заявки</a></li>
  <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(17)."\"><i class=\"fa fa-list mrr15\"></i>Мои заказы</a></li>
    <li class=\"mrt0\"><a class=\"side\" href=\"".$modx->makeUrl(19)."\"><i class=\"fa fa-user mrr15\"></i>Личные данные</a></li>";	
}
I know that it’s a three-story bike, but actually, after expelling its call to a higher level, actually in the body of the document itself:
[[$smrUserProfileTop]]
[[!If?
   &subject=`[[!urlGetValue? &field=`cpreq`]]`
   &operator=`empty`
   &then=`[[$smrProfileRequestUserList]]`
   &else=`[[$smrProfileRequestUserEditSwitch]]`
]]
[[$smrUserProfileBottom]]

everything worked. Thanks :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question