Add information in zend form and file upload fail - zend-framework

I have 2 problems. The first problem, that I have 2 input file (Zend_Form_Element_File) and each one of the input file have to redirect the file to a different directorys. I use Zend_File_Transfer_Adapter_Http to up the files.
the files to view related with the problem is:
Controller / Form / Upload Class
http://pastebin.com/6hTADeMQ
The other problem it's that I have to show a name of file related with the record that I load in Form when I edit a record. How I can insert a div and print this information. Follow the Zend Form File: http://pastebin.com/TPAaiEPz

Related

"chat.ejs" file shows before "index.ejs" file

I currently want a home page written in ejs, named "index.ejs" and a secondary chat function called "chat.ejs"
Here is the current file path
Image 1
The file named "chat.ejs" displays before "index.ejs"
How would I make index.ejs display first?
Thanks!
Colin

Cannot add a third content field

I'm kinda new to typo, so maybe I am just missing something.
I'm trying to add a third content field to Typo3 4.5.
What I've done so far.
Edit my template and added a new block
Added the block via TemplatVoila > Update Mapping > Modify DS / TO with Element Preset "Page-Content Elements [Pos.: 0]
Mapped it to the new block in the template
But I am missing something as the new field isn't showing up in the Page edit screen.
EDIT: I've found the Block in the "Edit page properties" but how to show it on standard edit screen?
Any added content area will appear automatically in your TV-View-module. So if you dont see it in there, then
you may have duplicate fields names
wrong column positions
or the existing template is using a »beLayout«-section, which shows only the first two content areas (see example in reference http://docs.typo3.org/typo3cms/extensions/templavoila/ExtTemplavoila/StaticDataStructures/ExampleForBelayout/Index.html)
The TemplaVoila template is split into TS (TemplaVoilà Template Object) and DS (TemplaVoilà Data Structure) records, may you paste the content of the field „Data Structure XML“ of the DS record here? In there are all necessary information.
The two template files should be located in your general storage folder, your TypoScript root file should be there as well.

Matching of data files to pages

I have used the assemble/boilerplate-site as a test bed. Following the examples on http://assemble.io/docs/Data.html I have created a page named test.hbs and a data file named test.yml.
The yaml file contains:
title: stuff
when running grunt assemble, a test.html page is assembled into the destination directory. if my test.hbs contains the tag {{title}} the title is not added from the data file, however a tag of {{test.title}} does add the title from the data file.
on the docs page http://assemble.io/docs/options-data.html it states:
When using "external" data files (versus YAML front matter), if name of the data file is the same as the associated template then Assemble will automatically associate the two files.
I also need to use the {{title}} tag in my layout. This works if I use YFM at the top of the page rather than an external data file.
Am I misunderstanding how external data files are associated with a page or am I missing something?
You can use {{page.title}} in your test.hbs and layout.hbs files to access the variable without having to specify the actual page name.

Zend Framework Dynamically added fields of a form and populate

I have been attempting to create a form where a user can simply press a button and the form will add a new field for the user to use. I have 2 of these dynamically added field types.
Firstly a field where a user can upload files, by pressing the add button another field is pasted underneath the current field and is ready for use.
I have followed an old guide on how to get this done with a bit of ajax and jQuery.
This guide to be exact: http://www.jeremykendall.net/2009/01/19/dynamically-adding-elements-to-zend-form/
As you can see it's from 2009 and a bit outdated yet it still works under the current Zend Framework version 1.11.11
The problem however arises now that i want an edit / update version of the form. I need to populate it's fields but first of all i need to create enough fields for the data to be stored in. So when there's 3 files that have been uploaded it should create 2 additional fields and place the 3 file names in these fields ready to be edited and updated. Simply using $form->populate($stuff) is not going to work
I just have no idea how to accomplish this and the tutorial on dynamically added fields only goes as far as the addAction and not how to create the editAction under these conditions.
Is there any tutorial out there on how to create and manage forms such as these? I'm sure i am not the only one who's had the idea to builds these kind of forms?
I can add my code if there's a request for it but it's the same as the example from the guide, just a different set of elements in the form.
Adding a small example of it's use.
A user adds an item with 3 files, these files are uploaded along with a filename so in the database it appears like this : File_Id : '1' , File_Name : 'SomeFile' , File_location : 'somewhere/on/my/pc/SomeFile.txt'.
Now the user realizes he forgot a file or wants to delete a file from that list, he goes to the edit page and here i want the form to display the previously added filenames. So if there's 3 files it shows 3 and when there's 2 it shows 2 etc. How do i build a form to dynamically add fields based on the number of uploaded files and then populate them?
Any advice on how to handle this is well appreciated :)
You can make use of the semi-magic setXxx() methods of the form.
Inside the form:
public function setFiles($files) {
foreach ($files as $file) {
$this->addElement(/* add a file element */);
//do other stuff, like decorators to show the file name, etc.
}
}
In your controller:
$files = $model->getFiles();
$form = new Form_EditFiles(array('files' => $files));
By passing an array with key files you will make the form try to call the method named setFiles(), which you have conveniently provided above.
This should push you in the right direction, or so I hope at least.
If I understand you correctly you want to populate file upload fields, which is not possible because of security reasons.
Edit:
You can add Elements inside of the Controller via $form->addElement() (basicly just like the $this->addElement() statements in the Tutorial)

Zend_Translate : How can be done with zend framework translation that will translate each expression according his html id?

I beginner in zend framework and its a bit hard for me to understand zend_translate how its works.
My Main Question:
How can be done with zend framework translation that will translate each expression according his html id and how non programmer translator can see word location in web browser for translate each expression according his content.
My Sub Questions:
1.How to update additional fields of csv file that holds translation of website?**
2.webpage original word url can not be seen in browser because he sub view that appear in parent form etc
If i have mistakes or you have better solution etc.. please write it.
My targets and partly solutions:
1.Give to non programmer making translation - I choose csv file.
2.Translate separately each word/expression according her appearance context on page and element id- I add columns webpage url and html id to csv file.
(But I have problem that sometimes webpage url can not be seen in browser because he sub view that appear in parent form etc..)
Example1:
view.phtml
........<div id="view-error"><?php translate("error was produced by empty") ?></div>....
......<div id="view-user-firstname"><?php translate("First Name") ?></div>....
My Implementation plan without zend code (I don't know how to do that with zend):
csv files columns names:
1.original word - original word that taking from the page to translate
<?php echo translate($original_word) ?>
2.spain/sweden translation - translation of original word
3.webpage url- webpage link to word translation location
(For translator important to know the location of word to check in which context she used)
4.html id - the id of html div/span/etc.. of translated word
||original word || spain translation ||sweden translation || webpage url || html id ||
Thanks
A regular practice is to have a separate file for each context.
For example each module can have its own translation source file
if you have modules like
modules/user
modules/categories
modules/products
modules/checkout
then you can create appropriate file for each module with all the phrases needs to be translated.
user.cvs
categories.cvs
products.cvs
checkout.cvs
It is not recommended to use URL because in most cases same phrases are used on many pages inside one specific module. So its better to provide a set of screenshots for translator of each page from the specific module.