Ok, so I have some smarty variables assigned on the checkout page in my shop. Problem is that when I want to use them -for example
{$address_collection.firstname}
I get an undefined index notice. I am certainly doing something wrong, but what?
on your screenshot $address_collection is array of objects, so to access to array element you need to use key, like $address_collection[124] and this element will contains address object,
where to get first name:
{$address_collection[124]->firstname}
If in smarty you want to access the array then you have to mention key of the array then you can use the values.If in your tpl file you want to print the array which you assigned then you have to write like
{var_dump($address_collection)}
Where $address_collection is the variable which from which you assigned values.
Now for access the values in your tpl file you have to mention key like:
{$address_collection['key_name']}
I hope it would help you.
Related
i use a lot of pm.collectionVariables.set() to temporary store variable from another request an re-use it again
we can see a list of Environment and Global Variable
but I don't know where to find a list of the stored collectionVariables.
It is in collection's information.
I want to localize a string that contains multiple placeholders.
E.g:
Hello %#1, today is %#2
I'd like to pass an array to the localization helper in my template like so:
{{loc "greetings" myArray}}
But that doesn't work, even though the documentation says it should.
What does work is
{{loc "greetings" "John" "Monday"}}
But the data I receive to display is an array and I don't want to store each element in a seperate variable.
How can I get the loc helper in the template to work with an array of data? Am I doing something wrong?
For the people how will fall here :
He gets his answer here : https://github.com/emberjs/ember.js/issues/16337
Loc should be/will be/is deprecated
A coldfusion query's column can be referenced like a 2D array from what I know of my past experience. Sometimes though I get this issue.
create query from spreadsheet
put column names into an array
only get first element when trying to access the row
have to use a workaround
//imports is a query object after this function
var imports = convertSpreadsheetWOHeaders(spreadsheet, 1);
//this is used to give name values in the json struct, not to access the query columns
var jsonHeaders = ListToArray("number,constructiontype,description,site_address,parcel,permit_date,note_Applicant,note_Contractor,valuation,note_Bld_Fees,note_Other_Fees");
//this gives me ["col_1","col_2","col_3",,,etc]. used to access query columns
var columnHeaders = imports.getColumnNames();
writeDump(imports[columnHeaders[1]]);
writeDump(imports);
I am left with just the first element in column one. And I get of course:
Message: You have attempted to dereference a scalar variable of type class java.lang.String as a structure with members.
When trying to do this:
structInsert(jsonStruct,jsonHeaders[j],imports[columnHeaders[j]][i]);
However, this works:
writeDump(ListToArray(ArrayToList(imports[columnHeaders[1]],'|'),'|',true));
I first do a dump of imports["col_1"] and i get only the first element.
Then I do a dump of ListToArray(ArrayToList(imports["col_1"])) like you see in the above image and it gives me the whole column.
Why can I not access the column correctly in the first place?
The Real Problem:
I was originally trying to access the jsonHeaders list as an array without doing ListToArray() on it. After that my function worked.
BUT. This next part is helpful.
When attempting to access a query object, doing queryObject["columnName"] is considered a shortcut of queryObject["columnName"][1] so coldfusion will just give you the first element.
But when I said ListToArray(ArrayToList()) coldfusion sees that ArrayToList MUST take in an array so an exception is made and the column is returned as an array.
To get a column back as an array to work with you can do a couple things
ListToArray(ArrayToList(query["column"]));
ListToArray(valueList(query.column));
valueArray(query, "column");
I am trying to write a program in C++ to read, manipulate, and update my database. I am having a problem inserting my data into mongo. So for my work flow, I get some type of request to update a document. I query the document, and update the data. I then try to do an update on the document.
I have a function that converts my class object to a BSONObj through a BSONObjBuilder. I seem to be having a problem with large arrays of sub-objects. For example, I have a field in my document called geo that looks like this:
geo: [{"postal": 10012},{"postal":10013},...,{"postal":90210}]
and is stored in C++ as:
std::vector<mongo::BSONObj> geo;
this field might have thousands of postal codes in it. When doing:
db.get()->update("db.collection",BSON("id"<<id_), BSON($set<<updateObj));
where updateObj is the obj I got from my BSONObjBuilder, nothing is updated in mongo. If I remove the geo field, everything is inserted.
I tried to just do
db.get()->update("db.collection",BSON("id"<<id_), BSON($set<<BSON("geo" << geo)));
thinking maybe it necessary to do separate queries due to the size of the obj and this also result in no update.
I was wondering if somehow I was hitting some sort of BSON size limit in C++.
The only reason I believe it is a size limit is because while trying to debug this problem, I tried to call updateObj.toString() in order to print out the object I was trying to insert and it threw an exception: Element extends past end of object. I assume that this means I hit some type of max size of an object/element.
Any insight into this problem will be greatly appreciated.
Thank you
I seemed to have figured it out. What happened was I got the geo field in one function, stored it in a vector and was using it in another. I did not used .Obj().copy() while storing the object in the vector, I just stored the .Obj() from the query results and when I went to insert I guess the invalid pointers blew up the BSONObj and caused an error.
I have a database where I store player names that belong to people who have certain items.
The items have and IDs, and subIDs.
The way I am currently storing everything is:
Each ID has its own collection
Within the collection there is a document for each subID.
The document for each subID is layed out like so:
{
"itemID":itemID,
"playerNames":[playerName1, playerName2, playerName3]
}
I need to be able to add to the list of playerNames quickly and efficiently.
Thank you!
If I understood your question correctly, you need to add items to the "playerNames" array. You can use one of the following operators:
If the player names array will have unique elements in it, use $addToSet
Otherwise, use $push