How does zend view render resolve path to view script - zend-framework

How does an action like this "customSearchAction()" map to the view script file name.
Neither of these file names work "customsearch.xml.phtml", "customSearch.xml.phtml", "custom-search.xml.phtml".
Please, note that I am using context switching view helper for xml, json. Also, the module and action are resolving properly. When I change the action name to "customsearchAction()" and name the rename the script file to "customsearch.xml.phtml", then it works.
So how is the view script file name resolved in the above case? in the Zend Framework

From documentation:
Note: Naming Conventions: Word Delimiters in Controller and Action Names
If your controller or action name is composed of several words, the dispatcher requires that these are separated on the URL by specific path and word delimiter characters. The ViewRenderer replaces any path delimiter found in the controller name with an actual path delimiter ('/'), and any word delimiter found with a dash ('-') when creating paths. Thus, a call to the action /foo.bar/baz.bat would dispatch to FooBarController::bazBatAction() in FooBarController.php, which would render foo-bar/baz-bat.phtml; a call to the action /bar_baz/baz-bat would dispatch to Bar_BazController::bazBatAction() in Bar/BazController.php (note the path separation) and render bar/baz/baz-bat.phtml.
Note that the in the second example, the module is still the default module, but that, because of the existence of a path separator, the controller receives the name Bar_BazController, in Bar/BazController.php. The ViewRenderer mimics the controller directory hierarchy.
So, from that custom-search.phtml is the right name. Now you are maybe wrong with the directory where you store it, what's the controller name (and module)? Check as well you view script is readable by apache.
Edit
In the case of ContextSwitch usage:
the initialisation is: $contextSwitch->addActionContext('custom-search', 'xml');
the view script is custom-search.xml.phtml
Just tested it on a ZF 1.6 (old but should still be valid). So maybe your initialization is wrong (used 'customSearch' instead of 'custom-search'?).

Related

"Two output file names resolved to the same output path" error when nesting more than one .resx file within form in .NET application

I have a Windows Forms .NET application in Visual Studio. Making a form "Localizable" adds a Form1.resx file nested below the form. I also want to add a separate .resx file for each form (Form1Resources.resx). This is used for custom form-specific resources, e.g. messages generated using the code behind.
This is set up as follows:
It would be tidier to nest the custom .resx file beneath the form (see this question for details about nest how to do this), as follows:
However, this results in the following error when I build the application:
Two output file names resolved to the same output path:
"obj\Debug\WindowsFormsApp1.Form1.resources" WindowsFormsApp1
I'm guessing that MSBuild uses some logic to find nested .resx files and generate .resources file based on its parent. Is there any way that this can be resolved?
Note that it is not possible to add custom messages to the Form1.resx file - this is for design-specific resources only and any resources that you add get overwritten when you save changes in design mode.
The error comes from the GenerateResource task because the 2 resx files (EmbeddedResource items in msbuild) passed both have the same ManifestResourceName metadata value. That values gets created by the CreateManifestResourceNames task and assumingly when it sees an EmbeddedResource which has the DependentUpon metadata set (to Form1.cs in your case) it always generates something of the form '$(RootNamespace).%(DependentUpon)': both your resx files end up with WindowsFormsApp1.Form1 as ManifestResourceName. Which could arguably be treated as the reason why having all resx files under Form1 is not tidier: it's not meant for it, requires extra fiddling, moreover it could be confusing for others since they'd typcially expect to contain the resx fils placed beneath a form to contain what it always does.
Anyway: there's at least 2 ways to work around this:
there's a Target called CreateCustomManifestResourceNames which is meant to be used for custom ManifestResourceName creation. A bit too much work for your case probably, just mentioning it for completeness
manually declare a ManifestResourceName yourself which doesn't clash with the other(s); if the metadata is already present it won't get overwritten by
Generic code sample:
<EmbeddedResource Include="Form1Resources.resx">
<DependentUpon>Form1.cs</DependentUpon>
<ManifestResourceName>$(RootNamespace).%(FileName)</ManifestResourceName>
...
</EmbeddedResource>

Meteor, coffeescript files running on every page

I am just getting started with Meteor and have encountered something that isn't necessarily an issue but something that I just don't understand. I have the following code in a file called chat.coffee...
Meteor.setInterval ( ->
console.log "Hello " + roomName
Meteor.call('keepAlive', Meteor.user(), roomName)
return
), 5000
I originally was under the impression that coffee-script files only ran on their associated html files. This doesn't seem to be the case here as this code runs on every single page regardless of the file name. Is this the intended way things are supposed to work, and if so, is there a way to enforce that only certain code runs on certain pages.
One thing to mention is that this code is running in the client side folder.
On the client side, Meteor will associate your templates with their javascript functions and helpers based upon shared template names, but that is not inherently tied to your file names.
By way of example, if you have a template named "chat" in an html file as follows:
<template name="chat"></template>
Meteor will run scripts such as Template.chat.helpers({}) or Template.chat.events({}) only in connection with the "chat" template. But that is not dependent on your file naming conventions. It could be placed in a file name chat.js for organization and convention, but could equally well reside in a file named client.js or any other arbitrarily named .js file.
Similarly, your <template name="chat"> could reside in a file named chat.html, or client.html, or an arbitrary name of your choosing.
Your setInterval function is not tied to a specific template so it will run on every page, even if it resides in a file named chat.js.
Correct.
Meteor merges all your javascript ( via coffeescript ) and all the html, which it stores in its own special way. It merges all the html in heads and body etc into a page and serves that up, and it will then render templates as you specify.
To have a more "page" oriented app you can use something like iron router.

Data binding - getBindingContext() returns absolute path rather than relative

I've got a table which I'm firing an event on row selection. In the handler I want to get the context for the selected row and then create a new context for a lower level oData object and then bind that to a Text view.
I'm sure there is a beautifully succinct way of doing this but currently I am:
Getting the binding path and adding a string to create a path to my lower level object:
var path = oEvent.getParameters().listItem.getBindingContext().sPath + "/ComplianceNote";
This is returning a path with / as the first character, from what I understand this means it's the root object of the service or this is an "absolute" path. My current workaround is to remove the first character:
path = path.substr(1, path.length);
Then I can bind my Text view:
noteText.bindElement(path);
noteText.bindProperty("text", "Note");
This works fine but seems to me to be a code smell hacking around with the string. My questions are:
Why is the path returned as "absolute" rather than "relative"
What is the correct way to achieve this. I've been looking at things like setBindContext and bindText.
Cheers,
Gregor

Autoloading classes in pimcore

I've created a fresh PHP-class, named it Application_Form_Login and saved it as Application_Form_Login.php inside the /website/lib directory. But everytime I'm running pimcore it refuses to load that file. What am I doing wrong here?
I've been looking at the Zend autoloader and trying to find out the issue.
I've noticed that in pimcore bootstrapping all the relevant directories are added to the include path. But they don't seem to get checked. Or maybe my file isn't named correctly to be picked up?
Your filename should be /website/lib/Application/Form/Login.php
From the page you just quoted:
Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace.

Zend Framework 1.9 addModuleDirectory not working?

Ok, I'm frustrated beyond words!
I have a ZF 1.9 application. The following is in my bootstrap.php:
$front = Zend_Controller_Front::getInstance();
$front->addModuleDirectory(dirname(__FILE__).'/modules');
I've put some trace code into the ZF library files, and I can see the call to addModuleDirectory and the subsequent internal call to addControllerDirectory - it's got the right values for the module name and the path. If I dump the internal _controllerDirectory variable (this is all in Library/Controller/Dispatcher/Standard.php, by the way), I can see my module directory.
The next thing my trace shows is that the default controller directory is added for the default controller - perfect.
However, on the next call to dispatch(), I'm again dumping the _controllerDirectory variable and it's only got the default module's controller directory. WTF? I have the trace going to a file... here it is (commented by me):
-- first call, triggered by addModuleDirectory():
Adding 13:09:08
Module itemquestion
Path /Users/don/Documents/Aptana Studio Workspace/cahoots2/application/modules/itemquestion/controllers
-- You can see my dir is in here...
_controllerDirectory contains: 13:09:08
/Users/don/Documents/Aptana Studio Workspace/cahoots2/application/modules/itemquestion/controllers
-- second call, triggered internally by ZF:
Adding 13:09:08
Module default
Path /Users/don/Documents/Aptana Studio Workspace/cahoots2/application/controllers
-- Where's my directory????
_controllerDirectory contains: 13:09:08
/Users/don/Documents/Aptana Studio Workspace/cahoots2/application/controllers
What in the world am I doing wrong? Why can't I get my module's directory to stay persistent?
EDIT: Some additional detail. I added a second module to the /modules folder. Now, I can see the first module being added and showing up in the _controllerDirectory variable. Then, I can see the second added, and see BOTH of them in the variable. Then I see the default module added and after that call, it's the only thing in _controllerDirectory.
Okay, it seems the solution is to add this to the application.ini:
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
Which is kinda unintuitive and at the very least not even remotely documented in the ZF reference manual. Oy. But this seems to have solved the problem.
Well I think it depends on what part you put it on the bootstrap, because, if you put it before the Application Resource Controller then it may overwrite. To make sure the front controller is bootstrapped you can use something like this:
protected function _initFrontModules() {
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$front->addModuleDirectory('path/to/modules');
}
If you omit the bootstrap line it may execute first your method and then overwrite it with the one from the plugin.