How to include view variable inside zend translate expression? - zend-framework

I want to display latest 3 news at my homepage. I select the latest news from table from MySql database and assign them to view variables in index controller, like this:
$this->view->latestNew = $someClass->getNewsfunction();
Then I declare it in view:
echo $this->translate->_($this->latestNew);
assuming that each time I will add a new row in my News table from MySql database, a unique header will be passed to Zend_Translate, which automatically will be detected by Poedit and proposed to be translated. But it won't work. The options like {$this->latestNew}, '$this->latestNew', "$this->latestNew" won't work neither. Any ideas?

One suggestion:
declare a literal to use in poedit and pass a variable as a parameter to it
In your view
printf($this->translate->_("title"), $this->latestNew);
in poEdit
source text: 'title'
translation text: %s
You can translate the content always with poEdit.

Related

TYPO3 FAL : add and read a custom field in a fluid template

In my custom extension I introduced a binary variable to the image metadata that needs to be read, similar to the "Show in list view" of tx_news.
With tx_news as example I was able to add the variable, the new palette shows the checkbox in the backend and the selection is registered in a new database field in the sys_file_reference table ...
I first tried to declare it in the domain which did work but I could not use the variable since it was an array of the same files in which I tried to use it, calling it within a loop broke the loop ... (this was my question)
now I need to use this new variable in my fluid template, if I loop trough the items the new variable named opentab is visible if I debug like this:
<f:for each="{object.items}" as="item" iteration="iteration">
<f:debug>{item.originalResource}</f:debug>
# debug result
TYPO3\CMS\Core\Resource\FileReferenceprototypeobject
propertiesOfFileReference => array(36 items)
uidOfFileReference => NULL
name => NULL
originalFile => TYPO3\CMS\Core\Resource\Fileprototypeobject
mergedProperties => array(empty)
propertiesOfFileReference has "title" which I can use like this {item.originalResource.title}
in propertiesOfFileReference I see "opentab" with its correct value but I found no way to use it !!!
Use {item.originalResource.properties.opentab}

Worklist template i18n <ObjectName>

Does the <ObjectName> refer to a variable which contains the name of the object? Or should I replace it manually with a suitable name?
The IDE generated #XTIT: Table view title worklistTableTitle=<ObjectName> in i18n.
The line which you have mentioned
#XTIT: Table view title worklistTableTitle=<ObjectName>
This is just a sort of comment in i18n file.
appDescription=<you can fill anything you can here> to reflect in your app.
When you use SAP WebIDE to create a template/application, it may create i18n files with placeholders for you to replace them with your own application specific texts. In your case, in the code below <ObjectName> represents a placeholder for your own text.
#XTIT: Table view title
worklistTableTitle=<ObjectName>
It does not refer to any variable, you simple have to add you own text in that field. Something similar to this :
#XTIT: Table view title
worklistTableTitle=My Products List

Cannot programmatically add content to simple HTML DIV Element in XML view

I have a simple XML view (fragment) like this:
<html:div id="holder"></html:div>
I want to add content programmatically like this:
var holder = this.byId("holder");
var label = new sap.m.Label({
text: "Label"
});
holder.addContent(label);
Effect is nothing, no error, no added content.
Why does it not work?
This is because content is not an aggregation (an easy mistake to make, since content usually is an aggregation).
sap.ui.core.HTML's content metadata object is a property of type string. From the jsdoc:
HTML content to be displayed, defined as a string.
You will need to use a different container for your label, such as sap.ui.layout.VerticalLayout, or you could just use raw HTML to stick in your holder object, rather than that sap.m.Label type.
Here is a jsbin that takes the XML view part of this question out of the equation.
Note: See #hirse's comment below for an important distinction when using html:div in XML views
The HTML element and the UI5 Controls are not directly compatible. UI5 Controls are JavaScript objects that have a render function. The render function creates a html fragment on demand. That html fragment ist then inserted into the page.
I have never tried it, but a solution could be to use the placeAt() method of your label:
label.placeAt("holder");
If you are using an XML View, the holder id will be prefixed. Then you should use something like this:
label.placeAt(this.getView().createId("holder"));
You can get DOM element of UI5 control by using getDomRef of sap.ui.core.Element class.
Then add your content to this DOM element by using placeAt()
Here is working example.

Word 2010 Show Table only in footer of last page

I've a template for word. In header and footer I've got logos of my company. The data of word is generating automatically from ERP program (that works great).
I only want to show some table with data on last page. I've tried this this method But it only works for text. When I'm updating the field the table and it's content disappear.
Anyone knows how to apply this method on table? It must to be automatic.
The same method works for block level content such as paragraphs or tables. Simply follow the same steps but instead of typing "Initials" insert your table there. Make sure to use speechmarks in the conditional e.g it should look like this { IF {PAGE} = {NUMPAGES} "" "(table)" }

How to add a custom field button to a field in SugarCRM

I looked through the developer blogs and I can only find ways to create a custom global form button or to replace a field with custom code. I don't want to replace the field, I want to add a button beside a field.
Here's what I have in mind:
[Date Field][date_picker_button] [time field][time_is_now]
The button I want to add is the time_is_now, allowing the user to populate the time field with the current time.
I have tried updating custom/modules/Notes/metadata/quickcreatedefs.php with:
array (
'name' => 'billable_start_c',
'label' => 'LBL_BILLABLE_START',
'customCode' => '<button</button>',
)
But this replaces the input field with the custom code. I could just put in the stock code and then my custom code, but date fields use yui and a widget, so I'd prefer not to.
Is there anyway to do something like:
'customCode' => '{default} <button></button>',
so that the default code gets output and then the custom code?
You could create a new SugarField template, which will essentially allow you to create the markup for your field. If you named your SugarField TimeIsNow, you could create a field with that type (instead of text,int, date or whatever). You should take a look at some of the other SugarFields to see how they are formatted, but it's really just HTML. When the field is set to that type, it pulls in that HTML template. You can tie your JS to the onclick function. Sugar is very easy to customize, so I definitely wouldn't get in the habit of solving all your customization needs this way...It's another way to look at it though.
Don't use custom code if you can help it. Either copy over the tpl to custom/modules/[yourmodule]/tpls/[yourtemplate] and code the bitton in there or use an after_ui_frame hook and some js to insert you custom button into the DOM.