Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sg_jobs
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor 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_jobs
Commits
ba7afba1
Commit
ba7afba1
authored
4 years ago
by
Tim Wagner
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Create JobTeaser plugin backend preview
parent
b9098756
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!24
[FEATURE] Plugin Previews
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Classes/Hooks/PageLayoutView/PluginRenderer.php
+43
-10
43 additions, 10 deletions
Classes/Hooks/PageLayoutView/PluginRenderer.php
Resources/Private/Templates/Backend/JobTeaser.html
+41
-0
41 additions, 0 deletions
Resources/Private/Templates/Backend/JobTeaser.html
with
84 additions
and
10 deletions
Classes/Hooks/PageLayoutView/PluginRenderer.php
+
43
−
10
View file @
ba7afba1
...
...
@@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use
TYPO3\CMS\Fluid\View\StandaloneView
;
/**
* Class PluginRenderer
* Class PluginRenderer
- Renders backend previews for plugins.
*
* @package SGalinski\SgJobs\Hooks\PageLayoutView
*/
...
...
@@ -55,7 +55,7 @@ class PluginRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHo
)[
'data'
][
'sDEF'
][
'lDEF'
];
$templateData
=
[
'redirectPage'
=>
$this
->
add
Title
sToRecordIdList
(
'redirectPage'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.redirectPage'
][
'vDEF'
]
),
'privacyPolicyPage'
=>
$pluginConfiguration
[
'settings.privacyPolicyPage'
][
'vDEF'
]
...
...
@@ -82,12 +82,12 @@ class PluginRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHo
$filterByExperienceLevel
=
$pluginConfiguration
[
'settings.filterByExperienceLevel'
][
'vDEF'
]
?:
''
;
$templateData
=
[
'applyPage'
=>
$this
->
add
Title
sToRecordIdList
(
'applyPage'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.applyPage'
][
'vDEF'
]
),
'jobLimit'
=>
$pluginConfiguration
[
'settings.jobLimit'
][
'vDEF'
],
'orderBy'
=>
$pluginConfiguration
[
'settings.orderBy'
][
'vDEF'
],
'filterByExperienceLevel'
=>
$this
->
add
Title
sToRecordIdList
(
'filterByExperienceLevel'
=>
$this
->
add
FieldContent
sToRecordIdList
(
'tx_sgjobs_domain_model_experience_level'
,
$filterByExperienceLevel
)
];
...
...
@@ -96,12 +96,42 @@ class PluginRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHo
// Also assign the standard plugin settings to the template
// as they are actually used in the corresponding controller action.
$view
->
assign
(
'storagePages'
,
$this
->
add
Title
sToRecordIdList
(
'pages'
,
$row
[
'pages'
]));
$view
->
assign
(
'storagePages'
,
$this
->
add
FieldContent
sToRecordIdList
(
'pages'
,
$row
[
'pages'
]));
$view
->
assign
(
'recursive'
,
$row
[
'recursive'
]);
$itemContent
.
=
$view
->
render
();
break
;
case
'sgjobs_jobteaser'
:
$drawItem
=
FALSE
;
$view
=
$this
->
createViewWithTemplate
(
'JobTeaser'
);
$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'
][
'sDEF'
][
'lDEF'
];
$templateData
=
[
'offersPage'
=>
$this
->
addFieldContentsToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.offersPage'
][
'vDEF'
]
),
'applyPage'
=>
$this
->
addFieldContentsToRecordIdList
(
'pages'
,
$pluginConfiguration
[
'settings.applyPage'
][
'vDEF'
]
),
'locations'
=>
$this
->
addFieldContentsToRecordIdList
(
'tx_sgjobs_domain_model_company'
,
$pluginConfiguration
[
'settings.locations'
][
'vDEF'
],
'name'
),
];
$view
->
assign
(
'data'
,
$templateData
);
$itemContent
.
=
$view
->
render
();
break
;
default
:
// No need to do anything
}
...
...
@@ -162,23 +192,26 @@ class PluginRenderer implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHo
}
/**
* Takes a comma-separated list of record IDs
and
the corresponding table.
* Returns another comma-space-separated list of the same records with the
titles
added.
* 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 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/JobTeaser.html
0 → 100644
+
41
−
0
View file @
ba7afba1
{namespace be=TYPO3\CMS\Backend\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_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.offers_page"
/>
</th>
<td>
{data.offersPage}
</td>
</tr>
<tr>
<th
scope=
"row"
>
<f:translate
key=
"LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.application_form_page"
/>
</th>
<td>
{data.applyPage}
</td>
</tr>
<tr>
<th
scope=
"row"
>
<f:translate
key=
"LLL:EXT:sg_jobs/Resources/Private/Language/locallang_db.xlf:tx_sgjobs_domain_model_job.teaser_locations"
/>
</th>
<td>
{data.locations}
</td>
</tr>
</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