Skip to content

Commit

Permalink
[TASK] update list template in order to remove unread information for…
Browse files Browse the repository at this point in the history
… links to pages and to external urls
  • Loading branch information
cdaecke committed Jul 12, 2019
1 parent 6ec04f6 commit 2a6cede
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 7 deletions.
39 changes: 39 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,45 @@ plugin.tx_mdunreadnews_unread {
}
}

/**
* used for ajax call to remove unread information
*
*/
PAGE_REMOVE_UNREAD_NEWS = PAGE
PAGE_REMOVE_UNREAD_NEWS {
typeNum = 120719

config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/html
xhtml_cleaning = 0
debug = 0
admPanel = 0
}

10 = USER_INT
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = MdUnreadnews
pluginName = Unread
vendorName = Mediadreams

switchableControllerActions {
Unreadnews {
1 = removeUnread
}
}

settings {
useStdWrap := addToList(newsUid)

newsUid = TEXT
newsUid.data = GP:newsUid
}
}
}


/**
* This lib can be used to show unread information of a news record
* Use following code in your fluid template
Expand Down
12 changes: 5 additions & 7 deletions Resources/Private/Partials/Unreadnews/ListItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@
<f:switch expression="{unreadnewsItem.news.type}">
<f:case value="1">
<f:comment>*** internal link ***</f:comment>
<f:link.typolink parameter="{unreadnewsItem.news.internalurl}">
<f:link.typolink parameter="{unreadnewsItem.news.internalurl}" class="more-link remove-unread" additionalAttributes="{'data-uid':'{unreadnewsItem.news.uid}'}">
<f:render section="NewsItem" arguments="{_all}" />
</f:link.typolink>
</f:case>
<f:case value="2">
<f:comment>*** external link ***</f:comment>
<f:link.typolink parameter="{unreadnewsItem.news.externalurl}" target="_blank">
<f:link.typolink parameter="{unreadnewsItem.news.externalurl}" class="more-link remove-unread" target="_blank" additionalAttributes="{'data-uid':'{unreadnewsItem.news.uid}'}">
<f:render section="NewsItem" arguments="{_all}" />
</f:link.typolink>
</f:case>
<f:defaultCase>
<f:comment>*** normal news record ***</f:comment>
<f:link.page pageUid="{singlePid}" additionalParams="{tx_news_pi1: '{news:unreadnewsItem.news.uid, controller:\'News\', action:\'detail\'}'}">
<f:render section="DefaultNews" arguments="{_all}" />
</f:link.page>
<f:render section="DefaultNews" arguments="{_all}" />
</f:defaultCase>
</f:switch>

<f:section name="DefaultNews">
<f:if condition="{settings.singlePid}">
<f:then>
<f:link.page pageUid="{settings.singlePid}" additionalParams="{tx_news_pi1: '{news:unreadnewsItem.news.uid, controller:\'News\', action:\'detail\'}'}">
<f:link.page pageUid="{settings.singlePid}" additionalParams="{tx_news_pi1: '{news:unreadnewsItem.news.uid, controller:\'News\', action:\'detail\'}'}" class="more-link">
<f:render section="NewsItem" arguments="{_all}" />
</f:link.page>
</f:then>
<f:else>
<f:link.page pageUid="{unreadnewsItem.news.firstCategory.singlePid}" additionalParams="{tx_news_pi1: '{news:unreadnewsItem.news.uid, controller:\'News\', action:\'detail\'}'}">
<f:link.page pageUid="{unreadnewsItem.news.firstCategory.singlePid}" additionalParams="{tx_news_pi1: '{news:unreadnewsItem.news.uid, controller:\'News\', action:\'detail\'}'}" class="more-link">
<f:render section="NewsItem" arguments="{_all}" />
</f:link.page>
</f:else>
Expand Down
21 changes: 21 additions & 0 deletions Resources/Private/Templates/Unreadnews/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,27 @@
<f:render partial="Unreadnews/ListItem" arguments="{unreadnewsItem: unreadnewsItem, settings: settings}" />
</f:for>
</f:widget.paginate>

<script type="text/javascript">
(function($){
// Remove unread information for news record
$('.remove-unread').click(function(e) {
var href = this.href,
hrefAjax = '/index.php?type=120719&newsUid='+$(this).data('uid'),
target = $(this).attr('target');

// if link is not opened in new window, call ajax and then follow link!
if (target != '_blank') {
e.preventDefault();
$.get(hrefAjax, function( data ) {
window.location = href;
});
} else {
$.get(hrefAjax);
}
});
})(jQuery);
</script>
</f:then>
<f:else>
<div class="no-news-found">
Expand Down

0 comments on commit 2a6cede

Please sign in to comment.