We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Programming a Random Reward System Based on Member's Site Browsing

Development and Programming

Genevieve's avatar
Genevieve
52 posts
15 years ago
Genevieve's avatar Genevieve

I have some potential clients who want some very custom functionality for their site, and ExpressionEngine will easily handle most of it, but there is one item on their list of requests that I can’t get my head around how to do so I’m hoping someone here can help me layout a logical plan of attack, at the very least. I have a basic grasp of PHP and Javascript programming, so I’m guessing I’m most likely going to need to hire someone to help me with this aspect of the project.

They want to have little windows pop up on random pages informing logged-in members that they have found a reward (the rewards are going to be downloadable items), and then have this reward show up in a little shopping-cart-like display that shows how many they have found and also has a link to where they can redeem their rewards. And each reward needs to be different (in other words, the rewards can’t repeat). The purpose of this system is to encourage clients to browse through the site.

So, as I see it (with my limited programming knowledge), there are three aspects to this: programming a script to generate pop-ups randomly, the pop-up generates a reward download (from a provided set of download links) and once an individual download link is generated it doesn’t get re-used for the member who is browsing, and then the download shows up in an area of the member’s account that can be accessed by the logged-in member whenever they want (and so keeps a history of rewards that have been found).

How would I go about building this into ExpressionEngine? Or how could I explain this to someone who could help me?

       
ender's avatar
ender
1,644 posts
15 years ago
ender's avatar ender

well one approach could go something like this:

1) create a channel/weblog for your downloadable rewards, each reward is an entry. 2) create a table in the database called something like member_rewards with reward_id as the primary key, member_id, and entry_id as int(10) fields acting as foreign keys to the exp_members and exp_weblog_titles tables, respectively 3) using some php in an embedded header template site-wide, generate a random number between 1 and whatever, then check to see if it exceeds some threshold (exact numbers determined by how often rewards should be generated). If the number doesn’t exceed the threshold then do nothing special and just show the page. 4) if the random number indicates that a reward should be shown, query the database to determine if that member has any unlinked rewards (select a random entry from the rewards channel that hasn’t already been recorded for that user in the custom table you made). 5) If the query comes back with a result then you show them what they’ve won and insert the record in the custom table linking their member_id and the entry_id of the downloadable reward

You could implement all of this “natively” in EE using relationships if you really wanted to, but you’d have to create an entry for each member because relationships only work between entries, not between members and entries. IMHO it’s easier to rig it up in your own table. A few relatively simple custom queries and a little PHP and you should be in good shape.

Feel free to PM me if you have questions about this or need a hand getting it rigged up 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.