Jump to content

versatilewt

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by versatilewt

  1. Thanks ChemicalBliss, The only thing is, I'm trying to have a generic class that can handle the simple cases and the variable case, and get the sub template out of the db if it's needed - and essentially examine the "replacements" array to see if it's necessary. I was kind of envisioning passing something like: array( '%customer_name%'=>'Bob', '%website_name%'=>'Acme', '%products%' = array( '0'=>array('%product_name%'=>'WidgetA', '%product_price%'=>'$1'), '1'=>array('%product_name%'=>'WidgetB', '%product_price%'=>'$2'), '2'=>array('%product_name%'=>'WidgetC', '%product_price%'=>'$3'), ) );
  2. Hi all, So I'm setting up a system that has a lot of emails, and variable replacement within it, so I'm writing a class to manage some variable replacement for templates stored in the database. Here's a brief example: // template is stored in db, so that's how this would get loaded in $template = "Hello, %customer_name%, thank you for contacting %website_name%"; // The array of replacements is built manually and passed to the class // with actual values being called from db $replacements = array('%customer_name%'=>'Bob', '%website_name%'=>'Acme'); $rendered = str_replace(array_keys($replacements), $replacements, $template); Now, that works well and good for single var replacements, basic stuff. However, there are some places where there should be a for loop, and I'm lost how to implement it. The idea is there'd be a template like this: Where, {products} would be an array passed to the template, which the is looped over for products requested, with a format like: So an example rendered version of this would be: What's the best way to accomplish this?
  3. I'm programming an application to automate business processes for a company. The system has a lot of notifications required, and I'm trying to think of the best way to set up the notification system. For example, when a customer replies to an email, it gets piped into the system and a sales rep gets an email. When a customer pays, a notification gets sent to the sales rep, the manager, and the vp of the divison. When an order ships, a notification gets sent to the sales rep, the manager, and the fulfillment department. So, my thought is to make a rules table, with the name of the rule for people that get notified in addition to the sales rep. Then, have a n:m table for users to rules, and when a notification should happen, look up the rule name in the db, find who gets notified, and send out the notifications. One thing I'm having an issue with is, how would I make a rule that references the particular sales rep (i.e. I'd make a rule to notify sales rep, but that sales rep would be different on every account - the n:m table for rules->users couldn't directly link to the actual sales rep, i'd have to be like a variable or something) I'm trying to keep this flexible for future considerations of rule changes (say the vp wants to stop getting copied on certain status updates). Any advice on the best way to go about something like this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.