NMS - insert external data

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Lineapixel
Forum Members
Forum Members
Posts: 62
Joined: Mon Oct 30, 2006 2:21 pm

NMS - insert external data

Post 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!
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: NMS - insert external data

Post by Jo Morg »

Maybe not what you were after but I replied on your original thread: http://forum.cmsmadesimple.org/viewtopi ... 46#p287646
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Lineapixel
Forum Members
Forum Members
Posts: 62
Joined: Mon Oct 30, 2006 2:21 pm

Re: NMS - insert external data

Post 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.
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: NMS - insert external data

Post 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. :)
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Lineapixel
Forum Members
Forum Members
Posts: 62
Joined: Mon Oct 30, 2006 2:21 pm

Re: NMS - insert external data

Post 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?
Post Reply

Return to “Modules/Add-Ons”