TYPO3 6.1
I wanted to call some function on opening of extbase news list view.
For example, if the url to list view contains tx_news_pi1[overwriteDemand][tags]=1, then I want to update that "tags" count by 1 in database.
How this could be possible ? Any help ?
And if You will just extend the class You need ?
config.tx_extbase {
objects {
Tx_FooExt_Controller_OriginalController.className = Tx_MyExt_Controller_OtherController
}
}
It looks like easiest way.
References
http://blog.sebastiaandejonge.com/articles/2013/june/11/class-extension-in-extbase/
http://lists.typo3.org/pipermail/typo3-english/2011-December/078458.html
The easiest way would be to just add a simple user function by TS and do it there
Related
Working with typo3 v 10.4, I have the requirement of some back-end user groups not to be allowed to move pages around. I was able to hide the arrow-actions shown in the page list view using the RecordListHookInterface. But drag and drop in the page tree still allows moving pages. Is there any TypoScript setting I can use to disable drag 'n' drop functionality of the page tree?
Unfortunately, there is no TypoScript configuration for this. But this can be done extending the "TreeController" from core with the "XClass" method:
<?php
namespace My\Namespace\XClass;
use TYPO3\CMS\Backend\Controller\Page\TreeController;
class XPageTreeController extends TreeController {
protected function isDragMoveAllowed(): bool {
if (!parent::isDragMoveAllowed()) {
return false;
}
$beUser = $this->getBackendUser();
return $beUser->isAdmin() || $beUser->isMemberOfGroup(123)
|| $beUser->isMemberOfGroup(234);
}
}
XClasses must be registered in the ext_localconf.php like so:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][TYPO3\CMS\Backend\Controller\Page\TreeController::class] = [
'className' => My\Namespace\XClass\XPageTreeController::class
];
Note that extending core classes has some disadvantages. For example, when switching to a newer Typo3 version, functionality might silently fail.
I have a like feature on my plugin where a user can like an idea, for that I have a mm table where I relate the idea and the user. I want to disable or enable the "like" button depending on if the user has liked the idea or not already.
When I call the $this->votedUsers from my model my fluid template gets this. What is this? Is not an array? How can I loop this to check if the user has liked the idea already.
This is what my $this->votedUsers property from my Idea model contains and I want to loop to check if that FrontendUser has liked the idea already and disable or enable de button.
This is how <f:debug>{_all}</f:debug> looks like
I would do this inside your idea model:
public function isLikedByCurrentUser(): bool
{
$currentUser = GeneralUtility::makeInstance(ObjectManager::class)
->get(FrontendUserRepository::class)
->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
if ($currentUser) {
return $this->votedUsers->contains($currentUser);
}
return false;
}
After that you can check it in Fluid via <f:if condition="{idea.likedByCurrentUser}"> ... </f:if>.
I am using powermail to allow a FE-User to edit a couple of fields of his own User-Record. Works fine, no hassle.
Now I would also like to allow the upload of a file. Is there a way to save the file to FAL with powermail? Unfortunately I have found no resources on this whatsoever. Maybe it is possible to implement a userfunc when saving to DB that would generate the required DB entries? When using powermails "upload"-field-type the file gets written to uploads/tx_powermail. I have access to that files path in my db_entry step in typoscript and could pass it on to a userfunc - which in return should
generate the sys_file entry
delete a possiblibly already existing sys_file_reference
generate the new sys_file_reference
Am I missing something?
Any ideas on this? Has anyone done something like this before?
Or is my only alternative to switch from powermail to a custom extbase extension?
System: TYPO3 7.6.16, Powermail 3.17
Thanks
I have same problems in powermail and i use powermail Finisher class like below.
TYPOSCRIPT:
plugin.tx_powermail.settings.setup {
finishers {
1 {
class = Vendor\Ext\Finisher\AddImageFinisher
config {
# set pid.
pid = TEXT
pid.value = 79 // Here
#set powermail fields title
field_name = Name
field_place = Place
field_email = E-Mail
field_message = Message
}
}
}
}
Please reffere this link. AddImageFinisher Class file
At the moment powermail don't uses FAL relations. If you need something like this, you have to add an own finisher that does the upload stuff - see https://docs.typo3.org/typo3cms/extensions/powermail/ForDevelopers/AddFinisherClasses/Index.html
Just for the record. TYPO3 8 core ships a new form extension which allows both. With the save to database finisher you can easily edit fe_user data. Furthermore, all image uploads are handled as FAL. We will document this use case and release a small extension which does the job (soon).
I created contact form in TYPO3 7.6.15 using standard form extension. I also created custom partial for it, and I defined it inside of my root template setup:
plugin.tx_form {
partialRootPaths {
20 = fileadmin/templates/ext/form/partials
}
}
Unfortunately it doesn't work and I am not sure why. I saw that the form extension for this TYPO3 version is still in beta phase...
Any help is greatly appreciated!
Denis
In the TYPO3 object browser, the paths to templates, layouts and partials are located in the object "view". So please try this:
plugin.tx_form {
view {
partialRootPaths.20 = fileadmin/templates/ext/form/partials/
}
}
I have no idea how I have to improve my listview in the backend module with a search or a filter (for only the records in the folder). That's why I don't have any code to show.
I actually have a list of all records and now I have to optimize this view for the administrator. This means I'd like to search over some columns and a filter to show only the records with the selected categorie from the dropdown.
I hope that someone can give me a hint, link or example how to realize something like that. I think it is a general thing how I can manipulate or integrate own php scripts or whatever.
Thanks for your help guys
Cheers
You can implement an filter method to you repository. Submit the form of filters to your index action an instead of $this->myRepository->fetchAll() make an function with filter: $this->myRepository->fetchByFilter($categorie).
In your repository class it looks something like that:
function fetchByFilter($categorie) {
$query = $this->createQuery();
$matching = [
$query->containts('categories', $categorie)
];
return $query->matching($query->logicalAnd($matching))->execute();
}
There might be such feature soon in the TYPO3 core (version 8.x), however doing such thing is not really easy.
An easier approach would be to use a custom backend module and render the content of the list module there again including the filter. You can take a look how I do it with the TYPO3 extension newssince version 5.0.
The contoller: https://github.com/TYPO3-extensions/news/blob/master/Classes/Controller/AdministrationController.php
Adding the filter for the record list: https://github.com/TYPO3-extensions/news/blob/master/Classes/Hooks/Backend/RecordListQueryHook8.php#L76
Hope that helps!