TypoScript
First of all: do you want to implement like_
in your own extension or do
you need like_
for a foreign extension?
Own Extension
We need to add some lines of TypoScript
-
Locate File
Open the
setup.
file of your extension. In most cases you should find it intyposcript [your
.Ext]/ Configuration/ Typo Script/ setup. typoscript -
Locate view Part
Find the part, where you define the template paths for fluid. In most cases you should find it here
plugin.
. See example based ontx_ [your Ext]. view maps2
:plugin.tx_maps2 { view { templateRootPaths { 0 = EXT:maps2/Resources/Private/Templates/ 10 = {$plugin.tx_maps2.view.templateRootPath} } partialRootPaths { 0 = EXT:maps2/Resources/Private/Partials/ 10 = {$plugin.tx_maps2.view.partialRootPath} } layoutRootPaths { 0 = EXT:maps2/Resources/Private/Layouts/ 10 = {$plugin.tx_maps2.view.layoutRootPath} } } }
Copied! -
Register Partial
like_
comes with a special fluid partial containing all the stuff it needs. You have to add that partial path to your TypoScript configuration. Please replaceit extkey
with the extension key of your extension. If your extension key contains underscores: remove them before pasting your extension key here.plugin.tx_extkey { view { templateRootPaths { 0 = EXT:extkey/Resources/Private/Templates/ 10 = {$plugin.tx_extkey.view.templateRootPath} } partialRootPaths { 0 = EXT:extkey/Resources/Private/Partials/ 10 = {$plugin.tx_extkey.view.partialRootPath} 20 = EXT:like_it/Resources/Private/Partials/ } layoutRootPaths { 0 = EXT:extkey/Resources/Private/Layouts/ 10 = {$plugin.tx_extkey.view.layoutRootPath} } } }
Copied! -
Add Partial to Your Template
With
like_
you can just like ONE record. It's not possible to like a collection of records. So, please locate and open the template file for single or detail view of a record. Pathit [your
is a good start to find the templates for detail view. Could beExt]/ Resources/ Private/ Templates/ Detail.
,html Single.
orhtml Properties.
. Search a good place to call thehtml like_
partial:it <f:render partial="Rating" arguments="{table: 'tablename_of_your_record', uid: object.uid}"/>
Copied! -
Add Dependency
As your extension now needs
like_
as dependency you should add it into yourit ext_
:emconf. php ... 'constraints' => [ 'depends' => [ 'typo3' => '10.4.36-11.5.99', 'like_it' => '2.0.0-2.99.99', ], 'conflicts' => [ ], 'suggests' => [ ], ], ...
Copied!And please update your
composer.
:json ... "require": { "typo3/cms-core": "^10.4.36 || ^11.5.23", "jweiland/like-it": "^2.0" }, ...
Copied! -
Done
Now you're ready. Please test the integration, check the database entries of
tx_
and check browser development console for any warnings and/or errors.likeit_ like
Foreign Extension
We need to add some lines of TypoScript into your site-package extension
to overwrite the TypoScript of the foreign extension. We prefer using
a site-package extension, but of cause, you can add these lines of
TypoScript also into TypoScript template records (sys_
).
-
Overwrite Foreign Fluid Template
Search for a detail view template file in the foreign extension and paste it into a directory somewhere in
Resources/
of your site-package extension.Private/... -
Overwrite Template Path
You have to inform Fluid to search for templates in path of your site-package extension first. Here an example how it can looks like for extension
events2
:plugin.tx_events2 { view { templateRootPaths { # Choose a value higher than the value of foreign extension. # In most cases 100 is enough. # If you're unsure check value in foreign extension or with # TypoScript Object Browser 100 = EXT:site_package/Resources/Private/Extensions/Events2/Templates/ } } }
Copied! -
Register Partial
like_
comes with a special fluid partial containing all the stuff it needs. You have to add that partial path to your TypoScript configuration.it plugin.tx_events2 { view { templateRootPaths { # see code from above } partialRootPaths { # Choose a value higher than the value of foreign extension. # In most cases 100 is enough. # If you're unsure check value in foreign extension or with # TypoScript Object Browser 100 = EXT:like_it/Resources/Private/Partials/ } } }
Copied! -
Add Partial to Overwritten Template
With
like_
you can just like ONE record. It's not possible to like a collection of records. Search a good place to call theit like_
partial in your overwritten detail view template:it <f:render partial="Rating" arguments="{table: 'tablename_of_foreign_record', uid: object.uid}"/>
Copied!For
news
it could look like:<f:render partial="Rating" arguments="{table: 'tx_news_domain_model_news', uid: newsItem.uid}"/>
Copied! -
Add dependency
As your site-package now needs
like_
as dependency you should add it into yourit ext_
:emconf. php ... 'constraints' => [ 'depends' => [ 'typo3' => '10.4.36-11.5.99', 'like_it' => '2.0.0-2.99.99', ], 'conflicts' => [ ], 'suggests' => [ ], ], ...
Copied!And please update your
composer.
:json ... "require": { "typo3/cms-core": "^10.4.36 || ^11.5.23", "jweiland/like-it": "^2.0" }, ...
Copied! -
Done
Now you're ready. Please test the integration, check the database entries of
tx_
and check browser development console for any warnings and/or errors.likeit_ like