[TYPO3-mvc] Understanding MVC
Robert Schneider
r.schneider at artworx.at
Fri Mar 22 11:54:09 CET 2013
Hi NG,
now I have to develop another extbase/fluid based extension. But I have
a problem understanding how to realize this in general.
I have used the extension builder which works fine so far. I have
checked those actions like create, delete, list and so on. This produces
a basic views where I can do all that CRUD stuff (currently, I'm only
dealing in the backend, however, the issue is the same for the frontend).
But this is really basic and I guess it is not the way how it gets
usually used. Who wants seperate pages for each object type? A list of
customers, a list of orders, a new customer forumalar page, ...
More likely the view gets designed different. But how to to do this with
view files, partial files and the controllers?
In my case I'd like to have a page where I see on the left side a list
of customers and a list of campaigns of the customer which get refreshed
if the customer gets changed. On the right side of the page there should
be a list of vouchers of the selected customer and the campaign. New
customers and campaigns should be added directly 'in the list'. They
should get renamed or deleted directly in the lists as well.
If I have an index action I can display all these things on the page.
Now, should this index action be part of the customer controller or
should I create another controller?
And what is if the user wants to add another customer? I don't want to
display another page. So I thought I could add a form onto the page that
gets shown if it is required. I think this is okay. And I could imagine
to have a partial file for the list with its customer specific actions.
But now, how do I present the whole page again after submit? I though
there would be an add action with a string parameter for the customers
name (currently the only property of the customer) that looks like this:
public function createAction($name) {
/** @var $customer Customer */
$customer = GeneralUtility::makeInstance(
'artworx\\Eldclickbelt\\Domain\\Model\\Customer');
$customer->setName($name);
$this->customerRepository->add($customer);
$persistenceManager = GeneralUtility::makeInstance(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
$persistenceManager->persistAll();
$this->forward('index', NULL, NULL, array(
'selectedCustomer' => $customer));
}
(This diverges from the extension-builders way with create/new. So is
this already a bad approach?)
Should I forward to the index action? Is this correct? I'm feeling
unsure with this. I suppose it is bad practice. Is a add.html file
better? What should I do?
In general I would say I do not understand how to build a page with many
elements and many different actions of many different controllers. I
don't want to have seperate pages for each 'create new' action. And I
think it will be wrong if each called action then redirects/forwards to
a global index action. Is it common and logical that an action defines
what to display next? And how do I deal with actions called via ajax?
Hm... many questions. I would be very happy if one could provide some
hints, concept, ideas. Are there any web sites regarding these themes?
Thank you and have a nice weekend!
Robert
More information about the TYPO3-project-typo3v4mvc
mailing list