Jump to content

Помощь с кодом


Recommended Posts

Парни,выручайте. В рнр я ноль ,ну может 0.1,не более. 

Есть код

     {{$location = $row != NULL ? $row : ($row->post != NULL ? $row->post : $row);}}
     {{$field_content = $row->post == NULL ? 'field_'.$location->database()->field_content : $row->post; $field_content = $row->post == NULL ? $location->$field_content : $field_content;}}
{{if \preg_match( '#<fileStore.core_Attachment>\S+(?:jpg|jpeg|png|webp)#', $field_content, $image_url )}}
       {{$image_url = \str_replace('<fileStore.core_Attachment>', \IPS\File::getClass('core_Attachment')->baseUrl(), $image_url[0]);}}
        {{if settings.lazy_load_enabled}}                 
			<a href="{$row->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$row->_title"}" >
			<img class='ipsImage' src='{expression="\IPS\Text\Parser::blankImage()"}' alt='{wordbreak="$row->_title"}' data-src='{file="$image_url" extension="core_Attachment"}'>
			</a>
			{{else}}
			<a href="{$row->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$row->_title"}" >
			<img class='ipsImage' alt='{wordbreak="$row->_title"}' src='{file="$image_url" extension="core_Attachment"}'>
			</a>                     
		{{endif}}
{{endif}}

Работает в Страницах: entry и recordRow / и Форумах: topicRow и topicRowSnnipet.

Но ни в какую не хотит фурыкать в файле forums/global/row

P.S Автор кода молчит...

Link to comment
Share on other sites

2 минуты назад, Desti сказал:

попробуй поменять $row на $topic

здесь у меня подозрение на строку 

     {{$field_content = $row->post == NULL ? 'field_'.$location->database()->field_content : $row->post; $field_content = $row->post == NULL ? $location->$field_content : $field_content;}}

потому что без этой строки ошибки нету,но и сам код не работает как надо.

Link to comment
Share on other sites

50 минут назад, AHristich сказал:

потому что без этой строки ошибки нету, но и сам код не работает как надо.

А вам не приходит в голову, что немного совсем наоборот? :) Переменной $row нет в вашем шаблоне, чего вы хотите получить-то? В последний шаблон передается переменная $topic, ее и надо использовать.

 

Link to comment
Share on other sites

3 минуты назад, Desti сказал:

А вам не приходит в голову, что немного совсем наоборот? :) Переменной $row нет в вашем шаблоне, чего вы хотите получить-то? В последний шаблон передается переменная $topic, ее и надо использовать.

 

Я в курсе что $row нету,поэтому использовал $topic (до создания темы о помощи) 

{{$location = $topic != NULL ? $topic : ($row->post != NULL ? $row->post : $row);}}
{{$field_content = $row->post == NULL ? 'field_'.$location->database()->field_content : $row->post; $field_content = $row->post == NULL ? $location->$field_content : $field_content;}}
{{if \preg_match( '#<fileStore.core_Attachment>\S+(?:jpg|jpeg|png|webp)#', $field_content, $image_url )}}
{{$image_url = \str_replace('<fileStore.core_Attachment>', \IPS\File::getClass('core_Attachment')->baseUrl(), $image_url[0]);}}
{{if settings.lazy_load_enabled}}                 
<a href="{$topic->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$topic->_title"}" >
<img class='ipsImage' src='{expression="\IPS\Text\Parser::blankImage()"}' alt='{wordbreak="$topic->_title"}' data-src='{file="$image_url" extension="core_Attachment"}'></a>
{{else}}
<a href="{$topic->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$topic->_title"}" >
<img class='ipsImage' alt='{wordbreak="$topic->_title"}' src='{file="$image_url" extension="core_Attachment"}'></a>                     
{{endif}}
{{endif}}

или я что-то не так делаю?

даже пробывал полностью все $row в этом коде заменить на $topic,бесполезно.

Link to comment
Share on other sites

7 часов назад, AHristich сказал:

Но ни в какую не хотит фурыкать в файле forums/global/row

где у тебя этот табличный шаблон выводится?

Link to comment
Share on other sites

46 минут назад, Exception сказал:

где у тебя этот табличный шаблон выводится?

Пытаюсь вывести в пользовательских блоках,там подключается этот шаблон.

Тесть создаю блок в Страницах,затем шаблон блока Лента тем форумов,вот там и подключается этот шаблон.

forums/global/row.html

Link to comment
Share on other sites

1 час назад, Desti сказал:

Все $row заменить на $topic. У вас даже в первой строке пара $row, реально не видите???

Это здесь не ту редакцию показал,менял абсолютно все $row

Link to comment
Share on other sites

можно первый пост загрузить с темы

{{$post = $topic->topic_firstpost ? \IPS\forums\Topic\Post::load($topic->topic_firstpost)->post : NULL;}}
{{if $post AND \preg_match( '#<fileStore.core_Attachment>\S+(?:jpg|jpeg|png|webp)#', $post, $image_url )}}
  {{$image_url = \str_replace('<fileStore.core_Attachment>', \IPS\File::getClass('core_Attachment')->baseUrl(), $image_url[0]);}}
  {{if settings.lazy_load_enabled}}                 
  <a href="{$topic->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$topic->_title"}" >
    <img class='ipsImage' src='{expression="\IPS\Text\Parser::blankImage()"}' alt='{wordbreak="$topic->_title"}' data-src='{file="$image_url" extension="core_Attachment"}'></a>
  {{else}}
  <a href="{$topic->url( "getPrefComment" )}" title="{lang="read_more_about" sprintf="$topic->_title"}" >
    <img class='ipsImage' alt='{wordbreak="$topic->_title"}' src='{file="$image_url" extension="core_Attachment"}'></a>                     
  {{endif}}
{{endif}}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Ваша ссылка была автоматически строена.   Отображать как обычную ссылку

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...