Extra Form
PHP PHP 7.3
CMS Rhymix 2.0

 

우선 다른 분들 검색시 도움이 될 수 있게 적절한 제목을 붙여야 하는데 뭐라고 해야할지도 몰라서 너무 포괄적인 제목을 붙여서 죄송합니다.

 

<span>{$document->get('voted_count') ? $document->get('voted_count') : '좋아요'}</span>

 

여기서 '좋아요' 부분을 다국어 작업을 위해 {$lang->like} 이렇게 넣었더니 바로 에러를 뿜었습니다.

 

<span>{$document->get('voted_count') ? $document->get('voted_count') : '{$lang->like}'}</span>

에러: ParseError #0 "syntax error, unexpected '}'

 

해결 방법이 있을까요?

  • profile

    {$document->get('voted_count') ? $document->get('voted_count') : '{$lang->like}'}

    굵게 표시된 부분이 템플릿 문법이므로 또다시 템플릿 문법을 사용할 이유는 없습니다. 또한 php 변수를 따옴표로 감싸면 변수 내용이 아니라 그냥 문자열이 그대로 출력될 뿐입니다.

     

    {$document->get('voted_count') ? $document->get('voted_count') : $lang->like}

    와 같이 작성하시면 됩니다.

  • profile profile
    와 시원한 답변 감사드립니다!