Page 1 of 1

NMS - insert external data

Posted: Mon Oct 08, 2012 7:23 am
by Lineapixel
Hi all.
I have a problem I'm not able to find a solution for.
I need to use NMS to send an email which should contain a couple of strings loaded from an external .csv file.
Well, the main problem is that each email must contain a different couple of strings (they're promo registration codes to a local exhibition, so every address must receive a different couple of codes taken from my list).
I'm not so good at coding, but I know how to read data from the external file with php.
What I don't know is how to make NMS addresses loop interact with my loop.

Thank you in advance for any kind of help!

Re: NMS - insert external data

Posted: Mon Oct 08, 2012 1:19 pm
by Jo Morg
Maybe not what you were after but I replied on your original thread: http://forum.cmsmadesimple.org/viewtopi ... 46#p287646

Re: NMS - insert external data

Posted: Mon Oct 08, 2012 1:47 pm
by Lineapixel
Thanks for your help.
I'd like to use the Username field for Name-Surname rather than the unique keys.
Furthermore most of the addresses are already in the database, so there's no need to import users.
This is why I was evaluating the chance to handle the csv as it is, without importing it, but (in my head) if I loop an array in the email body I'll have the whole array in each email, not just a record per message.
I have strong limits in my php/smarty knowledge, so I know there could be solutions I don't know.

Re: NMS - insert external data

Posted: Mon Oct 08, 2012 1:57 pm
by Jo Morg
I guess it is possible if you check inside the loop for a known var (such as the username and/or surname) and only render the correspondent value when there is a match.
However this brings a bit of overhead to the code since it has to run the loop for EVERY user. For few users that won't be a problem (or there may be other optimizations possible). But it may be a good starting point. :)

Re: NMS - insert external data

Posted: Mon Oct 08, 2012 2:07 pm
by Lineapixel
It's about 1000 emails.
I had an idea, but actually I don't know if it's possible (I guess so), but mostly I don't know how to do it:
I create a UDT to be inserted into the email content.
The tag should mainly do 4 things:
- call the csv file
- extract the first row from the array (couple of keys) to be used in the email content
- delete the row once extracted
- close the file

If I can do this, then I'll know that every message will get a unique couple of keys "consuming" the list.
Is there any way to do this?