Laminas: Different Layout Files for each Module - zend-framework

i would like to use a different layout file for each module which is set under view_manager- template_mapin the module.config.php
But for some reason both modules are always using the same Layout File. Is it not possible to use different layout files for each module ?

I have not worked on this question since ZF2 (2014) but at the time I wrote a module to answer your question. It is published on github at: https://github.com/dafap/DafapLayout
It will have to be adapted to Laminas (ZF3). To do this, replace the namespaces and edit the DafapLayout\Service\ConfigServiceFactory by replacing the createService() methods with __invoke().
Be careful, this module is in PSR0. Be sure to specify it in your composer.json otherwise it will not work.

Related

Swift C Interop: How to avoid absolute paths for modulemap headers?

I am working on building a swift wrapper over a C library (ROS2 RCL), using C interop features. I’m currently using CMake with module maps to achieve this functionality. Currently, my modulemap looks something like this:
module CRcl [system] {
header "/opt/ros/foxy/include/rcl/rcl.h"
link "rcl"
export *
}
This currently builds just fine on my system. However, using the absolute path is a pretty poor solution, as it requires modification for different os’s or custom install paths. I would prefer for it to be automatically discovered.
Ideally, I’d imagine something like this:
module CRcl [system] {
header "rcl/rcl.h"
link "rcl"
export *
}
where I don’t specify an absolute path, instead directing the compiler to find the header via a CLI arg or environment variable.
I have seen various guides for working with frameworks in XCode, but nothing that would be relevant for my setup on Linux. Does anyone know of a way to achieve this functionality?

TypoScript: Check if JS/CSS File is already included

anybody knows how to check if a js/css file is already included with typoscript?
Example
[Template_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
now if i got an extension with the same include e.g.
[Extension_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
Is there a way to prevent this kind of double code injection? Maybe i got another Template e.g. Template_B.ts where jquery is not included - than the Extension_A.ts has to include jquery by itself.
Kinldy
You can use the same key inside includeJS such it just gets overridden if you include the file twice.
Other than that you should put jQuery into includeJSlibs, such that it is loaded before the other JS files.
Other than that, the TS should be unique for each page. Therefore you always to make sure anyway that all resources are included in-order.
You should not include JS libs with the automatic extension TS setups. Use your documentation to tell the integrator what needs to be included and what not.
The various and independent inclusion of scripts by plugins and templates is one of the tricky points in TYPO3. As far as I know, this point cannot be managed at one single point.
There is a plugin "t3jquery" that offers to build, compress and share a common jQuery library. It also has a service to analyze other plugins for their dependencies. But this doesn't solve the problem in general, as many plugins don't check for libraries already loaded.
The most stable way is to remove all plugin's references to libraries manually in your TypoSkript. This gives you some simple additional TypoSkript lines. I use lines like these:
plugin.tx_imagecycle_pi1.file.jQueryLibrary >
plugin.tx_imagecycle_pi1.jQueryLibrary >
plugin.tx_multicontent_pi1.file.jQueryLibrary >
plugin.tx_multicontent_pi1.jQueryLibrary >
# Fluid
page.headerData.998 >
You can find the matching TypoSkript descriptors by searching for the library name in the TypoSkript browser or by greping in the plugin's source code. You will also need this if you wish to add libraries as part of content that was get by AJAX, thus separating the libs from the page content.
Here's a tut (in German): http://jweiland.net/typo3/typoscript/javascript-manuell-entfernen-oder-einbinden.html
Futher possibilities you can check:
Some plugins are written in good structure and offer to keep back their Javascript in the settings.
Some script inclusions may come rather from the static template but from a plugin, so don't forget to have a look there.

configuration in Zend Framework

i am new to ZF and i am making a project in ZF .i got basic knowledge of ZF but need more.
i studied configuration in ZF in many different ways like
Using Array Configuration
Creating File Configuration
Using INI File Configuration
Using XML File Configuration
i need to know what is best and efficient way among all these in sense of Maintainability and security ??
also can anyon plz tell me (Quick advise) how to start my first project so that its easy for me in order to maintain and upgrade.i am bit confuse with layouts that is header , footer and sidebar etc
how to intigrate this in my bootstrap like this but its not working
// Register the autoloader
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
// Initialise Zend_Layout's MVC helpers
Zend_Layout::startMvc(array('layoutPath' => ROOT_DIR.'/app/views/layouts'));
For configuration the answer is: use what you like best. All Zend_Config classes have same functionality. They just differ with the syntax.
As for something not working you must write more details. Again - what do you mean by 'not working'? What are the errors?

How to make Modules use Application View Helpers?

Since, adding some extra modules to the zend framework application, a lot of errors are popping out. By default, all the extra modules tend to use the same layout file to render a html, but for view helpes, it searches it's own folder.
In my case, I made a view helper, to load some template's css file. I named it LoadTemplate and placed it inside APPLICATION_PATH."/view/helpers"
It works perfectly, until I browse to a module. Then it gives a error saying
Plugin by name 'LoadTemplate' was not found in the registry; used paths: Custom_View_Helper_: x/x/application/modules/custom/views\helpers/ Zend_View_Helper_: Zend/View/Helper/
It is searching in the wrong folder.
Can't we tell it to search its folder first, and if not found go and find the helper from the default or Application's View Helper?
If your helper is in that directory, make sure it is called Zend_View_Helper_LoadTemplate, the function is called loadTemplate and the file name is LoadTemplate.php
Edit -
Also check out this blog post by Rob Allen: http://akrabat.com/zend-framework/view-helpers-in-modules/

zend framework under document root in subdir

I developed a application with Zend Framework and now I want to be able to place the app in an subdirectory of a Documentroot.
e.g. http://www.example.com/myapp/
I read quite a lot of Docu how this could work, but all in all these solutions don´t fit my needs. Is there a trivial way to do the subdir thing, without adding the concrete path to any file which generates the pages.
There are some examples in the net, where a basePath is set in the application enviroment and so there is a method call bevor each "form" creation which prepends the path before the link.
$form->setAction($this->_request->getBaseUrl() . $this->_helper->url('sign'));
This was from: http://johnmee.com/2008/11/zend-framework-quickstart-tutorial-deploy-to-a-subdirectory-instead-of-web-root/
But this is only works for small examples, I have tons of forms, tons of views and tons of scripts. I can´t belive this (lets call it hack :) ) is the only solution to do this.
Any ideas?
You don't have to do anything special. See my tutorial at http://akrabat.com/Zend-framework-tutorial which is developed entirely within a sub-directory.
As they say on the web page:
I’m told this last issue has been
lodged has a defect and not necessary
from releases “1.7″ and beyond. The
helper->url will henceforth prepend
the baseUrl to its result.
So you should be fine. Do you actually use the $form->setAction() method on every form already? Because if you use it in combination with the url helper, the baseUrl will already be included.