TYPO3: Backend Module render action of another Controller - typo3

I created a simple backend module for TYPO3 (7.6.15), with help of the ExtensionBuilder. The UserController and MediaController have a createAction, showAction and listAction. The PanelController just has the showAction which is the main view of the module and should look like this:
Now, I want to render the listActions from the other controllers in the template of the PanelController.showAction and I would like to do it in the template of the view (MyExt/Resources/Private/Templates/Panel/Show.html), if possible.
I appreciate all help in advance and wish everyone a nice day!

/**
* Redirects the request to another action and / or controller.
*
* #param string $actionName Name of the action to forward to
* #param string $controllerName Unqualified object name of the controller to forward to. If not specified, the current controller is used.
* #param string $extensionName Name of the extension containing the controller to forward to. If not specified, the current extension is assumed.
* #param array $arguments Arguments to pass to the target action
* #param integer $pageUid Target page uid. If NULL, the current page uid is used
* #param integer $delay (optional) The delay in seconds. Default is no delay.
* #param integer $statusCode (optional) The HTTP status code for the redirect. Default is "303 See Other"
*/
protected function redirect(
$actionName,
$controllerName = NULL,
$extensionName = NULL,
array $arguments = NULL,
$pageUid = NULL,
$delay = 0,
$statusCode = 303
)
You have to pass controller name and action name in redirect method to call action of another controller.
Please review above method that helps you.
or if you do it in template itself than may be you have to call viewhelper.

Okay, I haven't even realized for years that the question was still open. I simply loaded both external controllers to get all the data I needed. Then I passed the data to the correct view templates within the view itself, which were the views of the original list actions.

Related

TYPO3 - New, edit or delete action ignore redirect to list view

New, edit or delete action ignore redirect to list view, although it's defined in the controller. I added some fields and changed key definitions in the controller and now the new, edit or delete action ignores redirect to list view. Everything else works, it does create new or edit records. What am I missing?
Update action in controller:
/**
* action update
*
* #param \Vendor\Car\Domain\Model\Car $record
* #return void
*/
public function updateAction(\Vendor\Car\Domain\Model\Car $record) {
$this->addFlashMessage('The object was updated.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
$this->carRepository->update($record);
$this->redirect('list');
}
What fixed it was setting:
-List[42] // List View -> 'Exclude from speaking URL'
--Detail[43] // Detail View -> 'Hide in Menus'

In Extbase 6.2, don't use uid for list page

When using Extbase's "show" action:
<f:link.action action="show" arguments="{event : event}">
I would like to look up said event by a special column ('customID').
The actual TYPO3-uid should NOT appear in the URL (with or without RealURL).
The reason is that the data has been imported, and the "real" uid is 'customId'.
There's always #biesior's approach using f:link.page https://stackoverflow.com/a/26145125/160968 – but I thought I'd try it with the official way.
(how) is it possible to do that in extbase/fluid?
This is possible. Let's assume your model Event has a property customId. So you generate your link like this:
<f:link.action action="show" arguments="{event : event.customId}">
The link generated will have a queryString like this:
?tx_myext[event]=9999
The showAction generated by the Extension Builder expects that the UID of the event is passed. The PropertyMapper then fetches the object automatically and assigns it to the view:
/**
* action show
*
* #param \Your\Extension\Domain\Model\Event $event
* #return void
*/
public function showAction(\Your\Extension\Domain\Model\Event $event) {
$this->view->assign('event', $event);
}
But in your case you cannot fetch the object by UID because you passed the customId. So you need to fetch the object yourself:
/**
* action show
*
* #param integer $event
* #return void
*/
public function showAction($event) {
$event = $this->eventRepository->findOneByCustomId($event);
$this->view->assign('event', $event);
}
The annotation #param integer $event tells TYPO3 that the parameter is "just" an integer. You then call the magic method findOneByCustomId from your eventRepository. findOne indicates that you want exactly one Event object back (and not a QueryResult), while the ByCustomId that queries an existing property of your Event model.
Why not use realUrl with lookUpTable? See here: https://wiki.typo3.org/Realurl/manual#-.3ElookUpTable

TYPO3 - Personalize content of the box in backend

I've built a new content element type, and when you look in the backend, inside the box you can see the name of the module only. I'd like to change what information is show inside.
I could use the "header" field, but is there any way to use another field(s)?
Two answers
First answer
The field that's displayed there is the same field that's displayed in the list module. It is set in the table's TCA using ['ctrl']['label'] in the extension's ext_tables.php
$TCA['tx_myext_mytable'] = array(
'ctrl' => array(
'title' => 'My Table'
'label' => 'name_of_the_field_to_display_as_header'
// end snip
Second answer
If that is not enough for you, you can use a hook to display arbitrary HTML in the preview. The hook is called $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'].
The hook will be called with a function with this signature:
public function preProcess(
tx_cms_layout &$parentObject, // parent object
&$drawItem, // i have no idea what this is
&$headerContent, /* the content of the header
(the grey bar in the screenshot i think) */
&$itemContent, /* the content of the preview
(the white area in your screenshot */
array &$row // the content element's record
)
So all you have to do in that function is set the itemContent and, if you want, headerContent to whatever you want displayed.
Gotchas:
The output is inside of a span, so no block elements allowed in the
html. Any styling has to be done inline in the style attribute.
The function will be called on every content element, so you have to
check the row's CType and (if applicable) list_type fields so
that you only manipulate your own content elements.
An example can be found in the "fed" extension. I hope this helps.
Just a little update to adhominem answear #2 which is correct.
Today in TYPO3 6.2 and above your hook class has to inherit the interface TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface
It´s looks like belove
<?php
namespace TYPO3\CMS\Backend\View;
/**
* Interface for classes which hook into PageLayoutView and do additional
* tt_content_drawItem processing.
*
* #author Oliver Hader <oliver#typo3.org>
*/
interface PageLayoutViewDrawItemHookInterface {
/**
* Preprocesses the preview rendering of a content element.
*
* #param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* #param boolean $drawItem Whether to draw the item using the default functionalities
* #param string $headerContent Header content
* #param string $itemContent Item content
* #param array $row Record row of tt_content
* #return void
*/
public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row);
}
&$drawItem is boolean and send as reference and by changing it to $drawItem = false; will stop the default rendering of the preview.

Sudzc for Magento web services

I am in very bad situation, I got the objectiveC classes from the sudzc website.
using "http://www.xxx.in/mstore/api/soap/?wsdl"
in "SDZMagentoServiceExample.m" class I get one method
[service call:self action:#selector(callHandler:) sessionId: #"" resourcePath: #"catalog_category.level" args: (id)args];
It always gives me parameter error like
"Invalid website code requested:" if I pass dictionary or array in the args.
Please help me, I am in very bad situation.
thanks in advance.
From
/**
* Catalog category api
*
* #category Mage
* #package Mage_Catalog
* #author Magento Core Team <core#magentocommerce.com>
*/
class Mage_Catalog_Model_Category_Api extends Mage_Catalog_Model_Api_Resource
{
Following code:
/**
* Retrieve level of categories for category/store view/website
*
* #param string|int|null $website
* #param string|int|null $store
* #param int|null $categoryId
* #return array
*/
public function level($website = null, $store = null, $categoryId = null)
{
So nor array, nor dictionary would be accepted. Only raw string or int value.
I will not be able to help you in Objective C code, but I can show you some light with PHP. You can try out this type of call:-
$proxy = new SoapClient('http://www.iphone5case.in/mstore/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
/**
* As defined in the "Manage Stores" section of Admin panel,
* where you need to use the specific Website Code and/or Store Code
*/
$websiteCode = null;
$storeCode = 'german';
// Parent Category ID
$parentCategoryId = 2;
$firstLevel = $proxy->call($sessionId, 'category.level', array($websiteCode, $storeCode, $parentCategoryId));
Now if you print this variable "$firstLevel", you will get your required output, from this Web Service API.
Also whenever you are using Magento SOAP API v1, then each of the arguments will need to be as an array element. In this case, following are the main parameters expected for this API call "category.level":-
Website Code or ID
Store View Code or ID
Parent Category ID
So you need to create an array, and put sequentially each of the above arguments as array elements, like:-
array(
$websiteCode,
$storeCode,
$parentCategoryId
)
Lastly, please make sure that you reference this article always, as you can get the usage of almost all the Web Service API methods here.
Hope it helps.

zend rest route messing up routing for default controller

I have implemented a RESTful service by extending the Zend_Rest_Controller. The service works great. I have only one controller that actually has RESTful behavior. So I added the rest route for just that controller in the bootstrap.
protected function _initRestRoute()
{
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$restRoute = new Zend_Rest_Route($frontController, array() , array('default' => array('MyserviceController')));
$frontController->getRouter()->addRoute('rest', $restRoute);
}
problem starts when I run my portal zend app. The links in the layout for the index controller miss out on the action parameter when I construct the URL. For example the link on the index layout for a action homepage in the network controller is as follows.
$this->url(array('controller'=>'network','action'=>'homepage','module'=>'default'));
this should return "localhost/projectname/public/network/homepage" instead it returns "localhost/projectname/public/network". This behavior is only when the layout is loaded by the default controller i.e. IndexController. The routing problem vanishes if I remove the zend rest route from the bootstrap. As long as I am mentioning what controller the rest request has to route to it should not be a problem right. But this is affecting the default controller routing.
This seems to be a common issue and usually resolved with something like:
$this->url(array('controller'=>'network','action'=>'homepage','module'=>'default'), 'default');
or:
$this->url(array('controller'=>'network','action'=>'homepage','module'=>'default'), NULL, TRUE);
might work.
if your 'module'=>'default' is the default controllers directory at/application/controllers you can omit the module option from the route.
Here is the whole url method note the comments for the reset option.
/**
* Generates an url given the name of a route.
*
* #access public
*
* #param array $urlOptions Options passed to the assemble method of the Route object.
* #param mixed $name The name of a Route to use. If null it will use the current Route
* #param bool $reset Whether or not to reset the route defaults with those provided
* #return string Url for the link href attribute.
*/
public function url(array $urlOptions = array(), $name = null, $reset = false, $encode = true)
{
$router = Zend_Controller_Front::getInstance()->getRouter();
return $router->assemble($urlOptions, $name, $reset, $encode);
}