[TYPO3-mvc] I proudly present...
Sebastian Kurfürst
sebastian at typo3.org
Thu May 28 08:25:39 CEST 2009
Hey Susanne,
>> - Never get GET-Parameters with "$_GET['tx_addresses_pi1']['page'];" -
>> instead, use an annotation:
>>
>> /**
>> * @param integer $currentPage The current page
>> */
>> public function indexAction($currentPage = NULL) {
>> // Now, you'll have the parameter inside $currentPage
>> }
>
> Hmm... I don't understand. Where do I "fetch" the GET param now? Or how
> do I retrieve the value of currentPage?
Well.. If you generate a link in Fluid with an argument called
"currentPage", the URI generated by the URIBuilder will be like:
.....?tx_YourExtension_pi1[action]=index
&tx_YourExtension_pi1[controller]=Standard
&tx_YourExtension_pi1[currentPage]=27
You see that your argument is automatically prefixed.
Inside the controller, you specify via the annotation and the method
parameter that you expect a parameter named "currentPage" which is of
type "integer". The framework will now take the parameter from the
request, and give it to you as method parameter.
Thus, if you do an var_dump($currentPage), you'll see the current page
ID which was submitted.
The nice thing is: This works as well with whole objects, so you can do
stuff like:
<f:link.action .... arguments="{blog : blog}">...</f:link.action>
and inside the controller you do:
public function index(Tx_BlogExample_Domain_Model_Blog $blog) {}
The framework takes care of automatically just passing on the identity
of the blog, and rebuilding the object on the server side.
So, just forget some stuff you know about simple HTTP (especially forget
about $_GET and $_POST) and see that Extbase/FLOW3 bridges the gap
between requests very elegantly.
> I now use this instead:
>
> if($this->variableContainer->get('view')->getRequest()->hasArgument('page'))
> {
> $currentPage =
> $this->variableContainer->get('view')->getRequest()->getArgument('page');
> } else {
> $currentPage = 0;
> }
Just a sidenote: With beta1 this will change, we restructured this part
of Fluid a few days ago. It will be different to get the Request.
> To be honest I found the URIHelper a bit confusing - and I don't know
> how to get back a full <a> tag instead of just the URI, I'll have to
> take a deeper look at the weekend.
You can't right now. As said, programming a "widget" is still a bit
cumbersome right now, I think we will have some things changed in this
area. (f.e. I expect that a widget will have an own template just for
the widget).
Thanks for trying Extbase/Fluid,
Greets,
Sebastian
More information about the TYPO3-project-typo3v4mvc
mailing list