Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_news
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TYPO3
sg_news
Commits
11e27034
Commit
11e27034
authored
4 years ago
by
Tim Wagner
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Create backend preview for newsByAuthor news plugin
parent
501cf505
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!24
[FEATURE] Plugin Backend Previews
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Hooks/PageLayoutView/PluginRenderer.php
+57
-17
57 additions, 17 deletions
Classes/Hooks/PageLayoutView/PluginRenderer.php
Resources/Private/Templates/Backend/NewsByAuthor.html
+55
-0
55 additions, 0 deletions
Resources/Private/Templates/Backend/NewsByAuthor.html
with
112 additions
and
17 deletions
Classes/Hooks/PageLayoutView/PluginRenderer.php
+
57
−
17
View file @
11e27034
...
...
@@ -92,10 +92,10 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$templateData
=
[
'limit'
=>
$pluginConfiguration
[
'settings.limit'
][
'vDEF'
],
'categories'
=>
$this
->
add
Title
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.categories'
][
'vDEF'
]
??
''
'categories'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.categories'
][
'vDEF'
]
??
''
),
'tags'
=>
$this
->
add
Title
sToRecordIdList
(
'tags'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'sys_category'
,
$pluginConfiguration
[
'settings.tags'
][
'vDEF'
]
??
''
),
'starttime'
=>
$pluginConfiguration
[
'settings.starttime'
][
'vDEF'
],
...
...
@@ -123,10 +123,10 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$templateData
=
[
'newsLimitPerPage'
=>
$pluginConfiguration
[
'settings.newsLimitPerPage'
][
'vDEF'
],
'categories'
=>
$this
->
add
Title
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.categories'
][
'vDEF'
]
'categories'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.categories'
][
'vDEF'
]
),
'tags'
=>
$this
->
add
Title
sToRecordIdList
(
'tags'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'sys_category'
,
$pluginConfiguration
[
'settings.tags'
][
'vDEF'
]
),
'starttime'
=>
$pluginConfiguration
[
'settings.starttime'
][
'vDEF'
],
...
...
@@ -140,6 +140,45 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
$itemContent
.
=
$view
->
render
();
break
;
case
'sgnews_newsbyauthor'
:
$drawItem
=
FALSE
;
$view
=
$this
->
createViewWithTemplate
(
'NewsByAuthor'
);
$view
->
assign
(
'uid'
,
$row
[
'uid'
]);
$this
->
adaptPluginHeaderContent
(
$headerContent
,
$row
);
// Get available plugin settings and their values from flexform
$pluginConfiguration
=
GeneralUtility
::
xml2array
(
$row
[
'pi_flexform'
],
'T3DataStructure'
)[
'data'
][
'main'
][
'lDEF'
];
$templateData
=
[
'showDetails'
=>
$pluginConfiguration
[
'settings.showDetails'
][
'vDEF'
],
'newsAuthors'
=>
$this
->
addFieldContentsToRecordIdList
(
'tx_sgnews_domain_model_author'
,
$pluginConfiguration
[
'settings.newsAuthors'
][
'vDEF'
],
'name'
)
];
$backendUtility
=
GeneralUtility
::
makeInstance
(
BackendUtility
::
class
);
$excludedNewsIds
=
GeneralUtility
::
intExplode
(
','
,
$pluginConfiguration
[
'settings.excludedNews'
][
'vDEF'
],
TRUE
);
$excludedNewsListWithTitles
=
[];
foreach
(
$excludedNewsIds
as
$excludedNewsId
)
{
$excludedNewsListWithTitles
[]
=
$backendUtility
::
getRecord
(
'pages'
,
$excludedNewsId
,
'title'
)[
'title'
]
.
' ['
.
$excludedNewsId
.
']'
;
}
$templateData
[
'excludedNews'
]
=
$excludedNewsListWithTitles
;
$view
->
assign
(
'data'
,
$templateData
);
$itemContent
.
=
$view
->
render
();
break
;
default
:
// No need to do anything
}
...
...
@@ -153,9 +192,7 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
* @return StandaloneView
*/
protected
function
createViewWithTemplate
(
string
$templateName
):
StandaloneView
{
function
createViewWithTemplate
(
string
$templateName
):
StandaloneView
{
$view
=
GeneralUtility
::
makeInstance
(
StandaloneView
::
class
);
$view
->
setTemplateRootPaths
([
'EXT:sg_news/Resources/Private/Templates/Backend'
]);
$view
->
setPartialRootPaths
([
'EXT:sg_news/Resources/Private/Partials/Backend'
]);
...
...
@@ -201,23 +238,26 @@ class PluginRenderer implements PageLayoutViewDrawItemHookInterface {
}
/**
* Takes a comma-separated list of record IDs
and
the corresponding table.
* Returns another comma-space-separated list of the same records with the
record titles
added.
* The returned list look
s
nice enough to be rendered in the backend preview directly.
* Takes a comma-separated list of record IDs
,
the corresponding table
and optionally the field to look up
.
* Returns another comma-space-separated list of the same records with the
content of the field
added.
* The returned list
should
look nice enough to be rendered in the backend preview directly.
*
* @param $table
* @param $recordIdList
* @param string $table
* @param string $recordIdList
* @param string $field
* @return string
*/
protected
function
addTitlesToRecordIdList
(
string
$table
,
string
$recordIdList
):
string
{
protected
function
addFieldContentsToRecordIdList
(
string
$table
,
string
$recordIdList
,
string
$field
=
'title'
):
string
{
$backendUtility
=
GeneralUtility
::
makeInstance
(
BackendUtility
::
class
);
$recordIdsArray
=
GeneralUtility
::
intExplode
(
','
,
$recordIdList
,
TRUE
);
$recordsWithTitlesArray
=
[];
foreach
(
$recordIdsArray
as
$recordId
)
{
$recordsWithTitlesArray
[]
=
$backendUtility
::
getRecord
(
$table
,
$recordId
,
'title'
)[
'title'
]
.
' ['
.
$recordId
.
']'
;
$table
,
$recordId
,
$field
)[
$field
]
.
' ['
.
$recordId
.
']'
;
}
return
implode
(
', '
,
$recordsWithTitlesArray
);
}
...
...
This diff is collapsed.
Click to expand it.
Resources/Private/Templates/Backend/NewsByAuthor.html
0 → 100644
+
55
−
0
View file @
11e27034
{namespace be=TYPO3\CMS\Backend\ViewHelpers}
{namespace core=TYPO3\CMS\Core\ViewHelpers}
<be:link.editRecord
table=
"tt_content"
uid=
"{uid}"
>
<br/>
<table
class=
"table table-striped table-bordered"
>
<f:render
partial=
"PluginDataTableHeader"
/>
<tbody>
<tr>
<th
scope=
"row"
>
<f:translate
key=
"LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.showDetails"
/>
</th>
<td>
<f:if
condition=
"{data.showDetails}"
>
<f:then>
<core:icon
alternativeMarkupIdentifier=
"inline"
identifier=
"actions-check"
/>
</f:then>
<f:else>
<core:icon
alternativeMarkupIdentifier=
"inline"
identifier=
"actions-close"
/>
</f:else>
</f:if>
</td>
</tr>
<tr>
<th
scope=
"row"
>
<f:translate
key=
"LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.newsAuthor"
/>
</th>
<td>
{data.newsAuthors}
</td>
</tr>
<f:if
condition=
"{data.excludedNews}"
>
<tr>
<th
scope=
"row"
rowspan=
"0"
>
<f:translate
key=
"LLL:EXT:sg_news/Resources/Private/Language/locallang_db.xlf:plugin.flexForm.excludedNews"
/>
</th>
</tr>
<f:for
each=
"{data.excludedNews}"
as=
"excludedNews"
>
<tr>
<td>
{excludedNews}
</td>
</tr>
</f:for>
</f:if>
</tbody>
</table>
</be:link.editRecord>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment