Перейти к содержанию

Пометить тему прочитанной в активности (Mark this topic read) 4.6.4


Рекомендуемые сообщения

Не могу сказать, что перерыл абсолютно весь интернет, но на поиск решения потрачено уже порядка 10 часов
В общем, чего хочу добиться, чтобы в активности(https://ipbmafia.ru/discover/) можно было бы помечать темы как прочитанные, частично, мне этого удалось добиться, выводом этого блока предпросмотра над сообщением:
image.png.4f3bf5c46ef6144df37e8824dfdd2057.png
И оно вполне себе работает, но на телефонах нет курсора, чтобы его навести на название темы, поэтому решил кнопочку "Mark this topic read" вывести под пост:
image.png.a0d340f7b8a8902f99c8fc9bb03e35d7.png
Но ссылка (идентичная той, что в блоке предпросмотра) содержащаяся в "Mark this topic read" просто перекидывает в тему

Собственно вопрос, почему одна и та же ссылка работает по-разному и как это можно исправить
Вот код для searchResult с выводом блока предпросмотра и нерабочим "Mark this topic read":

Спойлер


{{$clv_a = preg_replace('/([\/^](&).+)/', '/&preview=1', $objectUrl);}}
{{$clv_b = $objectUrl->setQueryString('do','markRead')->csrf();}}
{{$clv_c = preg_replace('/(&comment=)+(\d)+/', '', $clv_b);}}
<li class='ipsStreamItem ipsStreamItem_contentBlock ipsStreamItem_{$view} ipsAreaBackground_reset ipsPad {{if isset( $indexData['index_class']::$searchResultClassName )}}{$indexData['index_class']::$searchResultClassName}{{endif}} {{if $indexData['index_hidden']}}ipsModerated{{endif}}' data-role='activityItem' data-timestamp='{$indexData['index_date_created']}'>
	<div class='ipsStreamItem_container ipsClearfix'>
		{{if \in_array( 'IPS\Content\Comment', class_parents( $indexData['index_class'] ) )}}
			{{$itemClass = $indexData['index_class']::$itemClass;}}
			<div class='ipsStreamItem_header ipsPhotoPanel ipsPhotoPanel_mini'>
				{{if $indexData['index_title']}}
					<span class='ipsStreamItem_contentType' data-ipsTooltip title='{lang="$itemClass::$title"}'><i class='fa fa-{$itemClass::$icon}'></i></span>
				{{else}}				
					<span class='ipsStreamItem_contentType' data-ipsTooltip title='{lang="$indexData['index_class']::$title"}'><i class='fa fa-{$indexData['index_class']::$icon}'></i></span>
				{{endif}}
				{template="userPhotoFromData" group="global" app="core" params="$authorData['member_id'], $authorData['name'], $authorData['members_seo_name'], \IPS\Member::photoUrl( $authorData ), ( $view !== 'condensed' ) ? 'mini' : 'tiny'"}
				<div class='{{if $unread}}ipsStreamItem_unread{{endif}}'>
					{{if $view == 'condensed' && $snippet}}
						<div class='ipsPhotoPanel ipsPhotoPanel_small'>
							{$snippet|raw}
							<div>
					{{endif}}
					<h2 class='ipsType_reset ipsStreamItem_title ipsContained_container {{if !$indexData['index_title'] or $view == 'condensed'}}ipsStreamItem_titleSmall{{endif}}'>
						{{if $unread}}
							<span>
								<a href='{{if member.member_id}}{$objectUrl->stripQueryString( array( 'comment' => 'comment', 'review' => 'review' ) )->setQueryString( 'do', 'getNewComment' )}{{else}}{$objectUrl->stripQueryString( array( 'comment' => 'comment', 'review' => 'review' ) )}{{endif}}' data-linkType="star" {{if $iPostedIn}}data-iPostedIn{{endif}} title='{lang="first_unread_post"}' data-ipsTooltip>
									<span class='ipsItemStatus {{if $iPostedIn}}ipsItemStatus_posted{{endif}}'><i class="fa fa-{{if $iPostedIn}}star{{else}}circle{{endif}}"></i></span>
								</a>
							</span>
						{{elseif $iPostedIn}}
							<span><span class='ipsItemStatus ipsItemStatus_read ipsItemStatus_posted'><i class="fa fa-star"></i></span></span>
						{{endif}}
						{{if isset( $indexData['index_prefix'] )}}
								<span>{template="prefix" group="global" app="core" params="rawurlencode($indexData['index_prefix']), $indexData['index_prefix']"}</span>
						{{endif}}
						<span class='ipsType_break ipsContained'>
							<a href='{$objectUrl}' data-linkType="link" data-searchable data-ipsHover data-ipsHover-target='$clv_a' data-ipsHover-timeout='1.5'>{{if ! empty( $itemData['extra']['solved'] ) }}<span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_positive" data-ipsTooltip title='{lang="this_is_solved"}'><i class='fa fa-check'></i></span>{{endif}} {$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['title'] ]}</a>
						</span>
						{{if $indexData['index_hidden']}}
								{{if $indexData['index_hidden'] === -1}}
								<span><span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_warning" data-ipsTooltip title='{lang="hidden"}'><i class='fa fa-eye-slash'></i></span></span>
								{{elseif $indexData['index_hidden'] === 1}}
								<span><span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_warning" data-ipsTooltip title='{lang="pending_approval"}'><i class='fa fa-warning'></i></span></span>
								{{endif}}
						{{endif}}
					</h2>
					{{if $view != 'condensed'}}
						<p class='ipsType_reset ipsStreamItem_status ipsType_blendLinks'>
							{expression="$itemClass::searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )"} <a href='{$containerUrl}'>{$containerTitle|raw}</a>
						</p>
					{{else}}
						<ul class='ipsList_inline ipsStreamItem_stats ipsType_light ipsType_blendLinks'>
							<li>
								<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'><i class='fa fa-clock-o'></i> {datetime="$indexData['index_date_created']"}</a>
							</li>
							{{if isset( $itemClass::$databaseColumnMap['num_comments'] ) and isset( $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ] ) and $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ] > ( $itemClass::$firstCommentRequired ? 1 : 0 )}}
								<li>
									<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'>
										{{if $itemClass::$firstCommentRequired}}
											<i class='fa fa-comment'></i> {expression="$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ]-1"}
										{{else}}
											<i class='fa fa-comment'></i> {expression="$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ]"}
										{{endif}}
									</a>
								</li>
							{{endif}}
							{{if isset( $itemClass::$databaseColumnMap['num_reviews'] ) and isset( $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_reviews'] ] ) and $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_reviews'] ]}}
								<li>
									<a href='{$itemUrl}#reviews' class='ipsType_blendLinks'><i class='fa fa-star-half-o'></i> {$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_reviews'] ]}</a>
								</li>
							{{endif}}
						</ul>

						<p class='ipsStreamItem_status ipsType_reset ipsType_blendLinks'>
							{expression="$itemClass::searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )"} <a href='{$containerUrl}'>{$containerTitle|raw}</a>
						</p>
					{{endif}}
					{{if isset( $indexData['index_tags'] ) and $view == 'condensed'}}
						<span>{template="tags" group="global" app="core" params="explode( ',', $indexData['index_tags'] ), true, true"}</span>
					{{endif}}
						
					{{if $view == 'condensed' && $snippet}}
							</div>
						</div>
					{{endif}}
				</div>
			</div>
			{{if $view !== 'condensed'}}
				<div class='ipsStreamItem_snippet ipsType_break'>
					{{if $canIgnoreComments and isset( $itemData['author'] ) and \IPS\Member::loggedIn()->member_id and isset( $authorData['member_id'] ) and isset ( $authorData['member_group_id'] ) and \IPS\Member::loggedIn()->isIgnoring( $authorData, 'topics' )}}
					<div class='ipsComment_ignored ipsType_light' id='elIgnoreComment_{$indexData['index_object_id']}' data-ignoreCommentID='elComment_{$indexData['index_object_id']}' data-ignoreUserID='{$authorData['member_id']}'>
						{lang="ignoring_content" sprintf="$authorData['name']"} <a href='#elIgnoreComment_{$indexData['index_object_id']}_menu' data-ipsMenu data-ipsMenu-menuID='elIgnoreComment_{$indexData['index_object_id']}_menu' data-ipsMenu-appendTo='#elIgnoreComment_{$indexData['index_object_id']}' data-action="ignoreOptions" title='{lang="see_post_ignore_options"}' class='ipsType_blendLinks'>{lang="options"} <i class='fa fa-caret-down'></i></a>
						<ul class='ipsMenu ipsHide' id='elIgnoreComment_{$indexData['index_object_id']}_menu'>
							<li class='ipsMenu_item ipsJS_show' data-ipsMenuValue='showPost'><a href='#'>{lang="show_this_post"}</a></li>
							<li class='ipsMenu_sep ipsJS_show'><hr></li>
							<li class='ipsMenu_item' data-ipsMenuValue='stopIgnoring'><a href='{url="app=core&module=system&controller=ignore&do=remove&id={$authorData['member_id']}" seoTemplate="ignore"}'>{lang="stop_ignoring_posts_by" sprintf="$authorData['name']"}</a></li>
							<li class='ipsMenu_item'><a href='{url="app=core&module=system&controller=ignore" seoTemplate="ignore"}'>{lang="change_ignore_preferences"}</a></li>
						</ul>
					</div>
					<div id='elComment_{$indexData['index_object_id']}' class="ipsHide">
						{$snippet|raw}
					</div>
					{{else}}
					 	{$snippet|raw}
					{{endif}}
				</div>
				<ul class='ipsList_inline ipsStreamItem_meta ipsGap:1'>
					<li class='ipsType_light ipsType_medium'>
						<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'><i class='fa fa-clock-o'></i> {datetime="$indexData['index_date_created']"}</a>
<p class='ipsType_reset ipsType_light ipsType_blendLinks'>&middot;
						<a href='{$clv_c}' data-action="markTopicRead"><i class="fa fa-check"></i> Mark this topic read</a></p>
					</li>
					{{if isset( $itemClass::$databaseColumnMap['num_comments'] ) and isset( $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ] ) and $itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ] > ( $itemClass::$firstCommentRequired ? 1 : 0 )}}
						<li class='ipsType_light ipsType_medium'>
							<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'>
								{{if $itemClass::$firstCommentRequired}}
									<i class='fa fa-comment'></i> {lang="num_replies" pluralize="$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ] - 1"}
								{{else}}
									<i class='fa fa-comment'></i> {lang="num_comments" pluralize="$itemData[ $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] ]"}
								{{endif}}
							</a>
						</li>
					{{endif}}
					{{if \IPS\IPS::classUsesTrait( $indexData['index_class'], 'IPS\Content\Reactable' ) and settings.reputation_enabled and \count( $reactions )}}
						{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}
							<li>{template="searchReaction" group="search" app="core" params="$reactions, $itemUrl->setQueryString('do', 'showReactionsReview')->setQueryString('review', $indexData['index_object_id']), $repCount"}</li>
						{{else}}
							<li>{template="searchReaction" group="search" app="core" params="$reactions, $itemUrl->setQueryString('do', 'showReactionsComment')->setQueryString('comment', $indexData['index_object_id']), $repCount"}</li>
						{{endif}}
					{{endif}}
					{{if isset( $indexData['index_tags'] )}}
						<li>{template="tags" group="global" app="core" params="explode( ',', $indexData['index_tags'] ), true"}</li>
					{{endif}}
				</ul>
			{{endif}}
		{{else}}
			{{$itemClass = $indexData['index_class'];}}

			<div class='ipsStreamItem_header {{if isset( $itemClass::$databaseColumnMap['author'] )}}ipsPhotoPanel ipsPhotoPanel_mini{{endif}}'>
				<span class='ipsStreamItem_contentType {{if !isset( $itemClass::$databaseColumnMap['author'] )}}ipsResponsive_hidePhone{{endif}}' data-ipsTooltip title='{lang="$indexData['index_class']::$title" ucfirst="true"}'><i class='fa fa-{$indexData['index_class']::$icon}'></i></span>
				{{if isset( $itemClass::$databaseColumnMap['author'] )}}
					{template="userPhotoFromData" group="global" app="core" params="$authorData['member_id'], $authorData['name'], $authorData['members_seo_name'], \IPS\Member::photoUrl( $authorData ), ( $view !== 'condensed' ) ? 'mini' : 'tiny'"}
				{{endif}}
				<div class='{{if $unread}}ipsStreamItem_unread{{endif}}'>
					{{if $view == 'condensed' && $snippet}}
						<div class='ipsPhotoPanel ipsPhotoPanel_small'>
							{$snippet|raw}
							<div>
					{{endif}}
					<h2 class='ipsType_reset ipsContained_container ipsStreamItem_title ipsType_break {{if $view == 'condensed'}}ipsStreamItem_titleSmall{{endif}}'>
						{{if $unread}}
							<span><a href='{{if member.member_id}}{$objectUrl->setQueryString( 'do', 'getNewComment' )}{{else}}{$objectUrl}{{endif}}' title='{lang="first_unread_post"}' data-linkType="star" {{if $iPostedIn}}data-iPostedIn{{endif}} data-ipsTooltip>
								<span class='ipsItemStatus {{if $iPostedIn}}ipsItemStatus_posted{{endif}}'><i class="fa fa-{{if $iPostedIn}}star{{else}}circle{{endif}}"></i></span>
							</a></span>
						{{elseif $iPostedIn}}
							<span class='ipsItemStatus ipsItemStatus_read ipsItemStatus_posted'><i class="fa fa-star"></i></span>
						{{endif}}
						{{if isset( $indexData['index_prefix'] )}}
							<span>{template="prefix" group="global" app="core" params="rawurlencode($indexData['index_prefix']), $indexData['index_prefix']"}</span>
						{{endif}}
						<span class='ipsContained ipsType_break'><a href='{$itemUrl}' data-linkType="link" data-searchable>{{if ! empty( $itemData['extra']['solved'] ) }}<span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_positive" data-ipsTooltip title='{lang="this_is_solved"}'><i class='fa fa-check'></i></span>{{endif}} {$indexData['index_title']}</a>
                        {{if $indexData['index_hidden']}}
							<span><span class="ipsBadge ipsBadge_icon ipsBadge_warning ipsBadge_medium " data-ipsTooltip title='{lang="hidden"}'><i class='fa fa-eye-slash'></i></span></span>
						{{endif}}
                        </span>

						{{if isset( $indexData['index_tags'] ) and $view == 'condensed'}}
							{template="tags" group="global" app="core" params="explode( ',', $indexData['index_tags'] ), true, true"}
						{{endif}}
					</h2>
					{{if $view != 'condensed'}}
						{{if $containerTitle}}
							<p class='ipsType_reset ipsStreamItem_status ipsType_blendLinks'>
								{expression="$itemClass::searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )"} <a href='{$containerUrl}'>{$containerTitle|raw}</a>
							</p>
						{{endif}}
					{{else}}
						<ul class='ipsList_inline ipsStreamItem_stats ipsType_light ipsType_blendLinks'>
							<li>
								<a href='{$objectUrl}' class='ipsType_blendLinks'><i class='fa fa-clock-o'></i> {datetime="$indexData['index_date_created']"}</a>
							</li>
							{{if isset( $indexData['index_class']::$databaseColumnMap['num_comments'] ) and isset( $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] ) and $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] > ( $indexData['index_class']::$firstCommentRequired ? 1 : 0 )}}
								<li>
									<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'>
										{{if $indexData['index_class']::$firstCommentRequired}}
											<i class='fa fa-comment'></i> {expression="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] - 1"}
										{{else}}
											<i class='fa fa-comment'></i> {expression="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ]"}
										{{endif}}
									</a>
								</li>
							{{endif}}
							{{if isset( $indexData['index_class']::$databaseColumnMap['num_reviews'] ) and isset( $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ] ) and $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ]}}
								<li>
									<a href='{$itemUrl}#reviews' class='ipsType_blendLinks'><i class='fa fa-star-half-o'></i> {expression="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ]"}</a>
								</li>
							{{endif}}
						</ul>
						{{if $containerTitle}}
							<p class='ipsStreamItem_status ipsType_reset ipsType_blendLinks'>
								{expression="$itemClass::searchResultSummaryLanguage( $authorData, $articles, $indexData, $itemData )"} <a href='{$containerUrl}'>{$containerTitle|raw}</a>
							</p>
						{{endif}}
					{{endif}}
					
					{{if $view == 'condensed' && $snippet}}
							</div>
						</div>
					{{endif}}
				</div>
			</div>
			{{if $view !== 'condensed'}}
				<div class='ipsStreamItem_snippet ipsType_break'>
					{$snippet|raw}
				</div>
				<ul class='ipsList_inline ipsStreamItem_meta ipsGap:1'>
					{{if isset( $indexData['index_class']::$databaseColumnMap['date'] )}}
						<li class='ipsType_light ipsType_medium'>
							<a href='{$objectUrl}' class='ipsType_blendLinks'><i class='fa fa-clock-o'></i> {datetime="$indexData['index_date_created']"}</a>
						</li>
					{{endif}}
					{{if isset( $indexData['index_class']::$databaseColumnMap['num_comments'] ) and isset( $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] ) and $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] > ( $indexData['index_class']::$firstCommentRequired ? 1 : 0 )}}
						<li class='ipsType_light ipsType_medium'>
							<a href='{{if $indexData['index_title']}}{$objectUrl}{{else}}{{if \in_array( 'IPS\Content\Review', class_parents( $indexData['index_class'] ) )}}{$objectUrl->setQueryString( array( 'do' => 'findReview', 'review' => $indexData['index_object_id'] ) )}{{else}}{$objectUrl->setQueryString( array( 'do' => 'findComment', 'comment' => $indexData['index_object_id'] ) )}{{endif}}{{endif}}' class='ipsType_blendLinks'>
								{{if $indexData['index_class']::$firstCommentRequired}}
									<i class='fa fa-comment'></i> {lang="num_replies" pluralize="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ] - 1"}
								{{else}}
									<i class='fa fa-comment'></i> {lang="num_comments" pluralize="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_comments'] ]"}
								{{endif}}
							</a>
						</li>
					{{endif}}
					{{if isset( $indexData['index_class']::$databaseColumnMap['num_reviews'] ) and isset( $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ] ) and $itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ]}}
						<li class='ipsType_light ipsType_medium'>
							<a href='{$itemUrl}#reviews' class='ipsType_blendLinks'><i class='fa fa-star-half-o'></i> {lang="num_reviews" pluralize="$itemData[ $indexData['index_class']::$databasePrefix . $indexData['index_class']::$databaseColumnMap['num_reviews'] ]"}</a>
						</li>
					{{endif}}
					{{if \IPS\IPS::classUsesTrait( $indexData['index_class'], 'IPS\Content\Reactable' ) and settings.reputation_enabled and \count( $reactions )}}
						<li>{template="searchReaction" group="search" app="core" params="$reactions, $itemUrl->setQueryString('do', 'showReactions'), $repCount"}</li>
					{{endif}}
					{{if isset( $indexData['index_tags'] )}}
						<li>{template="tags" group="global" app="core" params="explode( ',', $indexData['index_tags'] ), true"}</li>
					{{endif}}
				</ul>
			{{endif}}
		{{endif}}
	</div>
</li>

Я понимаю, что это не очень хороший код, но по другому я не умею

Ссылка на комментарий
Поделиться на другие сайты

После нажатия на ссылку в блоке предпросмотра, срабатывает этот js код:
 

Спойлер
;(function($, _, undefined) {
    "use strict";
    ips.controller.register('forums.front.forum.hovercard', {
        initialize: function() {
            this.on('click', '[data-action="markTopicRead"]', this.markTopicRead);
        },
        markTopicRead: function(e) {
            e.preventDefault();
            if ($(e.currentTarget).attr('data-disabled')) {
                return;
            }
            this.trigger('markTableRowRead', {
                tableID: 'topics',
                rowID: this.scope.attr('data-topicID')
            });
            ips.ui.flashMsg.show(ips.getString('topicMarkedRead'));
            ips.getAjax()($(e.currentTarget).attr('href'), {
                bypassRedirect: true
            });
            $(e.currentTarget).addClass('ipsFaded').attr('data-disabled');
        }
    });
}(jQuery, _));
;

 

Его по идее можно прикрутить к этой кнопке
image.png.a0d340f7b8a8902f99c8fc9bb03e35d7.png
Вот только пока не понимаю как, может кто-то делал что-то подобное?

Ссылка на комментарий
Поделиться на другие сайты

Для того, чтобы сработал скрипт, вы должны в родительском диве прописать (data-controller=) скрипт, который будет вызываться при нажатии на ссылку и передать в него параметры (например, data-topicid - номер темы). А в ссылке в свойстве data-action прописать название функции, которая должна вызваться. Если не прописать скрипт, будет просто переход по ссылке, что и происходит. 

<div class="..." data-controller="forums.front.forum.hovercard" data-topicid="3322">
   <a href="..." title="Отметить тему прочитанной" data-action="markTopicRead">Отметить тему прочитанной</a>
</div>                            

Ссылка на комментарий
Поделиться на другие сайты

Desti Огромное спасибо, получилось, правда я копировал весь div блока предпросмотра и встраивал в пост которому он принадлежит(через inspector Ctrl+Shift+i) и это не работало, думал, что не в этом дело, возможно data-controller и data-topicid при старте страницы инициализируются как активные или типа того
(плюсик поставлю позже, как только наберу необходимое кол-во постов)

Ссылка на комментарий
Поделиться на другие сайты

topicId должен  динамически присваиваться в шаблоне, а controller статичен ...data-topicID='{$topic->tid}'...

В предложенном виде это нормально для всплывающего окна, но для больших списков не гут, лучше перенести data-topiciID в ссылку, а в общем диве оставить только controller. 

 

Ссылка на комментарий
Поделиться на другие сайты

Desti Спасибо, поправил, так понимаю, теперь  ...data-topicID='{$topic->tid}'... будет определяться только при нажатии на ссылку?

Ссылка на комментарий
Поделиться на другие сайты

Нет, номер топика будет определяться при генерации страницы. Но если на каждую строку генерить пару data-controller и data-action, то в исходниках будет много лишнего хлама, поэтому data-controller выносят за пределы цикла перебора топиков и получается что-то типа

<div class="..." data-controller="forums.front.forum.hovercard">
   <a href="..." title="Отметить тему прочитанной" data-action="markTopicRead" data-topicid="3322"">Отметить тему прочитанной</a>
   <a href="..." title="Отметить тему прочитанной" data-action="markTopicRead" data-topicid="3323">Отметить тему прочитанной</a>
   <a href="..." title="Отметить тему прочитанной" data-action="markTopicRead" data-topicid="3324">Отметить тему прочитанной</a>
   <a href="..." title="Отметить тему прочитанной" data-action="markTopicRead" data-topicid="3325">Отметить тему прочитанной</a>
</div>  

Обработчик должен понимать, откуда ему брать данные. Если этот атрибут живет в родительском диве, то он доступен в скрипте по this.scope.attr('data-topicID'), а если в ссылке, то по $( e.currentTarget ).attr('data-topicID'), т.е. надо будет немного изменить JS, чтобы он брал нужные данные для работы со списком.

Ссылка на комментарий
Поделиться на другие сайты

Я слишком "прямо" вас изначально понял :bv:

6 часов назад, Desti сказал:

в родительском диве прописать (data-controller=)

Я взял и <a></a> обернул в div  ->  <div data-controller="forums.front.forum.hovercard"><a href="...">...</a></div>
теперь поправил, просто нашёл div в который встраивается ссылка и в него добавил data-controller
Спасибо вам ещё раз

Ссылка на комментарий
Поделиться на другие сайты

  • 1 месяц спустя...

Всем привет! Чтобы не поднимать новую тему напишу сюда, так как у меня похожая ситуация. Если кратко, хочу сделать так, чтобы при нажатии на иконку темы (см.скрин) к теме применялась функция "Прочитано", а не пройти к непрочитанным комментариям как сейчас, поскольку такая функция уже имеется по дефолту при нажатии названии самой темы. Подскажите как можно это реализовать?

Screenshot 2021-09-25 at 15-39-07 Саранский городской форум.png

Изменено пользователем deeverbs
Ссылка на комментарий
Поделиться на другие сайты

deeverbs откуда скрин? это блок? потому что в списке разделов и так при нажатии на иконки прочитывается всё.
если блок, то примеры выше, как это сделать.

Ссылка на комментарий
Поделиться на другие сайты

@by_ix
Скрин с блока Recent Topics, и в списке разделов, хотелось бы сделать чтобы при нажатии он в тему не провалился, а делал её только прочитанной)

Изменено пользователем deeverbs
Ссылка на комментарий
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.
Примечание: Ваш пост будет проверен модератором, прежде чем станет видимым.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

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

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

  • Последние посетители   0 пользователей онлайн

    • Ни одного зарегистрированного пользователя не просматривает данную страницу
×
×
  • Создать...