White paper: Templates in web-to-print.  Free download
Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
benadams  
#1 Posted : Tuesday, March 3, 2020 6:45:35 AM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
Hi everybody,

I' trying to copy a page with the same data.
ex: I have a business card with one page, in the customization, I'm trying to copy the current page to have a second page.
with the same informations et datas.

I want to know if its possible and how can I do it.

Actually, I save current file as statefile, and I want to reload it as printareas in my second page.
I don't know if its the right way.

Thanks for your help

VictorTolstov  
#2 Posted : Tuesday, March 3, 2020 7:46:54 AM(UTC)
VictorTolstov

Rank: Member

Groups: Member, Administration, Moderator
Joined: 11/14/2019(UTC)
Posts: 23

Was thanked: 1 time(s) in 1 post(s)
Hello Ben,

Could you explain in more detail about your user case. What are you trying to achieve and why do you need to initialize a second page with the same data.

For example, you can initialize the same design on interfaces and make text placeholders connected by using in-string placeholders
Documentation link: https://customerscanvas....-and-text-validation.htm paragraph Populate Several Elements With a Single Value

Both placeholders shoud have similar name and value like this in square brackets with a hash sign: [#name]

Regards, Victor
benadams  
#3 Posted : Tuesday, March 3, 2020 3:36:05 PM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
This is a solution given.
But I want to initialize a second page with the same current design .

I try another example.
I have a template PSD file with black background and field name. the user want to create business card with two faces(French side and English side)
he starts the customization in French by changing background from black to green and add text with content "infographiste-french", then want to duplicate this current customization as second page to make the English side.

How can I do it with Customer canvas.
VictorTolstov  
#4 Posted : Wednesday, March 4, 2020 4:19:49 AM(UTC)
VictorTolstov

Rank: Member

Groups: Member, Administration, Moderator
Joined: 11/14/2019(UTC)
Posts: 23

Was thanked: 1 time(s) in 1 post(s)
Ben,

Could you additionally tell how the process, in your opinion, occurs, when you switch from the first surface to the second surface, it is completely copied?
Such a setting can lead to the fact that when switching from the second to the first, the second will save all changes to the first. Or if you change the first one again, the changes will be applied to the second.

Could you describe the logic of how this should work

Regards, Victor
benadams  
#5 Posted : Wednesday, March 4, 2020 6:36:01 AM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
No Tolstykh,
the copy is made once, when the second page is created by duplicating the first one.
After this process, each page is independent. Modifications on the first page don't affect the second page, vice versa.

If the user make update on the design of the first page and want to update the second one, he has to delete the second page and copy the first one again as second page.

I hope I express myself clearly (Excuse my English level, I use to speak French)


VictorTolstov  
#6 Posted : Wednesday, March 4, 2020 8:50:08 AM(UTC)
VictorTolstov

Rank: Member

Groups: Member, Administration, Moderator
Joined: 11/14/2019(UTC)
Posts: 23

Was thanked: 1 time(s) in 1 post(s)
Ben,

If you want to create an additional surface, the following option will suit you:
It is best to add a new surface at the click of a button using the following code:

let product = await editor.getProduct();
let productModel = await product.getProductModel();
newSurface = productModel._surfaces._collection[0].clone();
productModel._surfaces._collection.push(newSurface);
product.setProductModel(productModel);

This code copies the existing design and adds it to the object model

Regards, Victor

Edited by user Wednesday, March 4, 2020 8:51:47 AM(UTC)  | Reason: Not specified

benadams  
#7 Posted : Thursday, March 5, 2020 8:08:37 AM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
Thanks Victor,
I will try it and give you a feedback
benadams  
#8 Posted : Saturday, March 7, 2020 1:23:59 PM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
HI VICTOR

WHEN I USE the code
i have an error telling me that
product.getProductModel(); is not a function and is undefined.


HERE IS MY CODE
$('.copy_design').click(function() {
var product = editor.getProduct();
var productModel = product.getProductModel();
newSurface = productModel._surfaces._collection[0].clone();
productModel._surfaces._collection.push(newSurface);
product.setProductModel(productModel);


});

Thanks again

VictorTolstov  
#9 Posted : Tuesday, March 10, 2020 4:46:13 AM(UTC)
VictorTolstov

Rank: Member

Groups: Member, Administration, Moderator
Joined: 11/14/2019(UTC)
Posts: 23

Was thanked: 1 time(s) in 1 post(s)
Hello Ben,

When calling the LOADEDITER method, you should have the following line:

CustomersCanvas.IframeApi.loadEditor(editorFrame[0], product, configuration)
.then((e) => {
editor = window.editor = e;
})

If the problem persists, send the entire sample code that you are using.

Regards, Victor
benadams  
#10 Posted : Wednesday, March 11, 2020 12:08:55 PM(UTC)
benadams

Rank: Advanced Member

Groups: Member
Joined: 3/20/2018(UTC)
Posts: 56

Thanks: 4 times
HI,
my code to clone a page is :

$('.copy_design').click(function() {

// Loading the editor.
CustomersCanvas.IframeApi.loadEditor(editorFrame[0], productDefinition, configuration)
//If the editor has been successfully loaded.
.then(function (e) {
editor = e;

var product = editor.getProduct();
var productModel = product.getProductModel();
var newSurface = productModel._surfaces._collection[0].clone();
productModel._surfaces._collection.push(newSurface);
product.setProductModel(productModel);
})
//If there was an error thrown when loading the editor.
.catch(function (error) {
loadData = handleError(error, "Load failed with exception: ");
});




//



});


I have the same error " product.getProductModel()" is not a function;

Idon't know if design atom work with IFrame API. But I fail to get the product model.

is there any way to clone a page without ATOM in IFrame API?.

Thanks
VictorTolstov  
#11 Posted : Wednesday, March 11, 2020 11:47:21 PM(UTC)
VictorTolstov

Rank: Member

Groups: Member, Administration, Moderator
Joined: 11/14/2019(UTC)
Posts: 23

Was thanked: 1 time(s) in 1 post(s)
Hello Ben,

Pay attention to the use of await, because methods getProduct and getProductModel return promises must be processed asynchronously. Use the code with await:

var product = await editor.getProduct();
var productModel = await product.getProductModel();
var newSurface = productModel._surfaces._collection[0].clone();
productModel._surfaces._collection.push(newSurface);
product.setProductModel(productModel);

Regards, Victor
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.