Creating a FrontEnd Plugin in Typo3 7.6 - php

I know there are multiple Threads with a similar Question but I hope that someone can give me an individual solution.
So I am working on an Existing Typo3 7.6.23 Project with already multiple plugins running, I tried to copy every instance that I could find to replicate a plugin and customize it for my use. That didn't work. I couldn't see the Plugin in the Dropdown List.
Then I tried to follow the steps from this link.
(1) registerPlugin
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
$_EXTKEY,
'DocumentService',
'DokumentenService'
);
(2) configurePlugin
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'TYPO3.' . $_EXTKEY, 'DocumentService', array(
'Example' => 'showDocumentService',
),
// non-cacheable actions
array(
'Example' => '',
)
);
I should be able to select the Plugin in the Backend Dropdown List. But it just does not appear in my Plugins List in the Content Element where I need it.
I even created a Template in the Right Folder and created an Action for it in the Controller..
I'm stuck here and would love to hear a solution as soon as possible.

You are writing about about a service.... Ist the extension just a typo3 Service, you won't be able to select it as extension in the backend...
Have a look at "ext_localconf..."
Is there a \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(...
Then the extension could be just a service.

Here is a working sample from Aimeos Webshop. Please note you have to change the name of the plugin, you should not use TYPO3. or Aimeos. for the plugin name instead choose your own name.
configurePlugin example from https://github.com/aimeos/aimeos-typo3/blob/2018.04/ext_localconf.php#L27, this configures your plugin for the frontend:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Aimeos.' . $_EXTKEY,
'locale-select',
array( 'Locale' => 'select' ),
array( 'Locale' => 'select' )
);
registerPlugin example https://github.com/aimeos/aimeos-typo3/blob/2018.04/ext_tables.php#L60, this shows your plugin in the backend:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Aimeos.' . $_EXTKEY,
'locale-select',
'Aimeos Shop - Locale selector'
);
And here is the entry point of the action https://github.com/aimeos/aimeos-typo3/blob/2018.04/Classes/Controller/LocaleController.php#L27
The Extension Builder can help you to setup a new TYPO3 extension and is available for TYPO3 v7.6 too see https://extensions.typo3.org/extension/extension_builder/.
And finally here is the documentation on writing extensions for TYPO3 v7.6 https://docs.typo3.org/m/typo3/reference-coreapi/7.6/en-us/ExtensionArchitecture/Index.html.

Related

The socialengine widget content in the new created module is not get appear in the front end

I created a new module using the tutotorial https://jadb.wordpress.com/2011/04/22/social-engine-4-modules/
Its working as fine.
later i created a widget in the new module using the tutorial. https://jadb.wordpress.com/2011/01/17/socialengine-4-create-a-widget/
The widget folder was not created during the module creation time. so i created folder for widgets.
and also i added Controller.php and index.tpl files.
After i added the code mentioned in the tutorial to content.php file ,my new widget appeared on the admin side in layout editor.
After i add my widget to page and save it, I don't see it's content on page.
I have added my file contents here. my module name is LoginPhonenumber
and widget name is hione.
content.php
<?php
return array(
array(
'title' => 'Hi One',
'description' => 'hi123',
'category' => 'Login Phonenumber',
'type' => 'widget',
'name' => 'login-phonenumber.hione',
'requirements' => array(
'no-subject',
),
),
) ?>
Controller.php
<?php
class LoginPhonenumber_Widget_HioneController extends
Engine_Content_Widget_Abstract
{
public function indexAction()
{
echo "hiiiiiiiiiiiiiiii";
}
}
?>
index.tpl
<?php echo "Welcome";?>
Can anyone tell me where is the problem.
I suggest you to change your module's name: none of core modules uses kind of naming similar to login-phonenumber. All modules are named as one single word:
As you can see, even if module name contains more than one word, they're named as a single word, without dashes. In case if you'll use module with dash inside you'll most probably receive next warning:
WARN (4): exception 'Engine_Content_Exception' with message 'Widget's module is not enabled or not installed: "login-phonenumber"'
which allows us to understand that SocialEngine can't identify a module with such name, even if its name in database as login-phonenumber.

TYPO3: Extension to run PHP code

This is more like a basic question:
How do I get an extension (by Extension Builder) to run a simple PHP code without adding a domain model and actions?
In general, there are 3 options:
Create a content element which is answered here: With fluid_styled_content, how to create custom content elements in TYPO3 7.5 and 7 LTS?
Create a plugin which is from the "old" kind, former called "pi_base".
Create a plugin based on extbase.
I would still go with option number 3 and therefore you still will need an action. Having actions is good because of you add a 2nd variant, you can just use a 2nd action and there is not much additional code you need.
Having such an extension is fairly easy. One example I did lately was this extension: https://github.com/sup7even/mailchimp
In general you need:
ext_localconf.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Sup7even.' . $_EXTKEY,
'Registration',
array(
'Form' => 'index,response,ajaxResponse'
),
array(
'Form' => 'index,response,ajaxResponse'
)
);
ext_tables.php
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Sup7.' . $_EXTKEY,
'Registration',
'Mailchimp'
);
And the RegistrationController. By default, the first action will be called which is in this case index, therefore you need an indexAction and the Template must be Templates/Registration/Index.html.

ZF2 'unable to render template' when shifting module names in the array in app config

Good day.
I've just started learning ZF2, replicated the Album example step-by-step, and then decided to make it a bit more interesting by adding user registration, and then make the two work together in some way, so i added a new 'Auth' module.
So, when i only had one module in the module list (aside from the Application module) in application.config.php, it was all fine, but when i added the Auth module to the list like so:
'modules' => array('Application', 'Album','Auth',)
i got the following error when trying to access any views from the album module which was working absolutely fine prior to this change:
Zend\View\Renderer\PhpRenderer::render: Unable to render template "album/album/index"; resolver could not resolve to a file
But when i changed the order in which the modules are presented in this array like so:
'modules' => array('Application', 'Auth','Album',)
not a single view (and it has only one) from the Auth module could be rendered, while the Album module was fine.
Zend\View\Renderer\PhpRenderer::render: Unable to render template "auth/user/index"; resolver could not resolve to a file
Both of these views exist at these locations, but the renderer doesn't see them for some reason.
You can see the project's contents here.
Thank you for any tips in advance.
Looks like you copy pasted the the view manager config for Auth module.config.php.
This should be auth rather than album for your templates to work correctly.
'view_manager' => array(
'template_path_stack' => array(
'auth' => __DIR__ . '/../view',
),
),

Does not show newly created module in Layout

I'm trying to list my newly created module(account_test) that copied from "account" module in OpenCart 2.x (account module shows in backend system->design->layouts-> edit home layout). I have duplicated all account php & tpl files to account_test & tpl files and change all references from account to account_test in both admin & catalog module/language/view folders.
Also, I noticed in admin\controller\design\layout.php the if statement which add only Account & Category modules to Layouts setting:
if ($this->config->has($code . '_status') || $module_data) {
$data['extensions'][] = array(
'name' => $this->language->get('heading_title'),
'code' => $code,
'module' => $module_data
);
}
If i remove the if condition :
$data['extensions'][] = array(
'name' => $this->language->get('heading_title'),
'code' => $code,
'module' => $module_data
);
It will add all modules to layouts view, but none of them working except old modules
Stuck in this for few days, Any ideas to list newly created module to layouts admin section and front end?
Is you module get installed or not? If you followed correctly then it must be listed in admin->extension->modules. And then from there you have to first install it and then enable it. And also make sure the controller file named properly.
Edit
$this->config->has($code . '_status') checks whether you module is installed or not i.e. is it in setting table or not. Check in setting table for your module code.

Phalconphp routing for multimodule application

I've created a multimodule application using phalconphp developer tool:
phalcon project <projectname> module
And I've added a backend module (the frontend is generated). Now I would like all backend routing do the following:
$route->add('/admin/:controller/:action/:param', array(
'module' => 'backend',
'controller' => 1,
'action' => 2,
'params' => 3,
));
But my routing also defines:
$router->setDefaultModule("frontend");
$router->setDefaultNamespace("Groendesign\Backend\Controllers");
And therefor when I browse to: http://myprojectname/admin it searches in my backend module for the frontend Namespaces, How should I proceed with this?
What I want to achieve is that every url that has the prefix /admin/ is send to the backend module. Using the url to define which controller, action and parameters.
I've fixed this by removing the setDefaultNamespace from my bootstrap and adding it to the Modules.php file in each Module. Thereby setting the DefaultNamespace only in the correct module.

Categories