The document discusses a client's request to export member data from ExpressionEngine into Excel. It describes counting to 10 to think of solutions rather than immediately saying no. It then explains how the author used lateral thinking to create a template-based member export tool that generates a CSV file for the selected date range, protecting it from public access. This allows exporting member data for use in other software, resolving the client's request.
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Count to 10 and Say Yes
1. Count to 10 and Say Yes
JOHN HENRY DONOVAN
Engine Summit 7th June 2011
2.
3. Introduction
We have all been there. A client emails and makes an unreasonable
feature request. Our first response after the explosion of expletives
would be to say no. But let's count to 10 and rescue the situation.
4. Lateral thinking
• For me personally, lateral thinking plays a big part when designing
architecture for a clients web application/site
• It's problem solving at it's lowest common denominator
• In ExpressionEngine these problems present themselves all the
time. I call it problem solving but it is really solution finding
• Lateral thinking comes into play the more you become aware of the
flexibility that EE has to offer. Your solution depends on the tools
and knowledge you have at hand. It's about taking something you
know and applying or seeing it in a different way.
• Lets examine one of the most common over thought items in EE
7. The Member Export Tool
"We want to be able to export our members into Excel. Looking at
them in EE is all well and good but I want the data available to our
non-webeditors also. We have an a piece of software here in the
office that we want to import our members into"
8. The Member Export Tool
IMMEDIATE THOUGHTS
• I just built you a whole website in ExpressionEngine, why do you
need to do this??
• There must be an add-on that does what they want
• Punt the cat down the stairs
9. The Member Export Tool
LETS THINK ABOUT THIS
• What are the exact reasons behind the client wanting this
• There must be a gap in the workflow I created for them
• It is something out of scope so lets do our best to make his flawless
• Lets cover all angles
• Lets turn this into a project that we can charge a client for and be
happy with the outcome
10. The Member Export Tool
SPEC
• Export as a downloadable CSV file
• Choose today's date
• Choose a specific date
• Choose a date range
• Make it all template based
• Protect it from the public
15. /member-export/index (continued)
<body>
{if logged_out}
<h1>Bugger off!</h1>
<p>You must be a site administrator to view this page.</p>
{if:else}
<h1>Member Data Custom Export Tool</h1>
<form action="" id="export-tool">
<input type="text" value="Choose dates" id="range" />
<input class="submit" type="submit" value="Download"/>
</form>
{/if}
</body>
</html>
16. The Member Export Tool
member-export
exporter
today specific date date range
member-export.csv
17. /member-export/exporter
{if segment_3 == "" AND segment_4 == ""}
<h1>Bugger off!</h1>
<p>You must be a site administrator to view this page.</p>
{/if}
<!-- Check for todays date and show correct embed -->
{if segment_3 == "{current_time format='%Y-%m-%d'}" AND segment_4 == ""}
{embed="member-export/today" date1="{current_time format='Y-%m-%d'}"}
{/if}
<!-- Check for a specific date and show correct embed -->
{if segment_3 != "{current_time format='Y-%m-%d'}" AND segment_4 == "" AND segment_3 != ""}
{embed="member-export/specific-date" date1="{segment_3}"}
{/if}
<!-- Check for a date range and show correct embed -->
{if segment_3 != "" && segment_4 != ""}
{embed="member-export/date-range" date1="{segment_3}" date2="{segment_4}"}
{/if}
18. The Member Export Tool
member-export
exporter
today specific date date range
member-export.csv
19. /member-export/today
{exp:ajw_export sql="SELECT
m.member_id AS 'Website Member Id',
date_format(from_unixtime(join_date), '%d/%m/%Y') AS 'Join Date',
m.username AS 'Username',
m.email AS 'Email',
m.url AS 'URL',
m_field_id_1 AS 'Subscribed to Newsletter'
FROM exp_members AS m LEFT JOIN exp_member_data AS d ON d.member_id = m.member_id
WHERE date_format(from_unixtime(join_date), '%d-%m-%Y')='{embed:date1}'
ORDER BY m.member_id DESC"
format="csv" filename="member-export.csv"
}
20. /member-export/specific-date
{exp:ajw_export sql="SELECT
m.member_id AS 'Website Member Id',
date_format(from_unixtime(join_date), '%d/%m/%Y') AS 'Join Date',
m.username AS 'Username',
m.email AS 'Email',
m.url AS 'URL',
m_field_id_1 AS 'Subscribed to Newsletter'
FROM exp_members AS m LEFT JOIN exp_member_data AS d ON d.member_id = m.member_id
WHERE date_format(from_unixtime(join_date), '%d-%m-%Y')='{embed:date1}'
ORDER BY m.member_id DESC"
format="csv" filename="member-export.csv"
}
21. /member-export/date-range
{exp:ajw_export sql="SELECT
m.member_id AS 'Website Member Id',
date_format(from_unixtime(join_date), '%d/%m/%Y') AS 'Join Date',
m.username AS 'Username',
m.email AS 'Email',
m.url AS 'URL',
m_field_id_1 AS 'Subscribed to Newsletter'
FROM exp_members AS m LEFT JOIN exp_member_data AS d ON d.member_id = m.member_id
WHERE date_format(from_unixtime(join_date), '%Y-%m-%d') BETWEEN '{embed:date1}' AND
'{embed:date2}'
ORDER BY m.member_id DESC"
format="csv" filename="member-export.csv"
}