Share
Embed
Iain Urquhart - #eeciconf
Edging your way into #EECMS development.
When you’re a designer.
iainurquhart
May 30, 2012
Transcript
53 slides
-
Edging your way into #EECMS development. When you’re a designer.
@iain | #EECI2012 EU Wednesday, 30 May 12 -
Hai. @iain | #EECI2012 EU I’m @iain 1998 - Art
School 2003 - Graphic & Web Design 2006 - ExpressionEngine 2009 - First Add-ons I fly solo most of the time, handling design, development and account management for my projects. Maintain a handful of add-ons which are by-products of my work. Wednesday, 30 May 12 -
Assumption. By Development I mean extending #EECMS @iain | #EECI2012
EU Getting EE do do stuff it doesn’t do ‘out of the box’ Wednesday, 30 May 12 -
Why start learning EE dev? When is the right time?
Personal experience: dev fundamentals that I really struggled with What resources helped me (and didn’t help me) get me started with development Areas of CodeIgniter docs to bookmark when starting out How to get help Managing client expectations Working within your bounds General tips, open discussion What I’m going to talk about: @iain | #EECI2012 EU Wednesday, 30 May 12 -
Why bother? @iain | #EECI2012 EU Surely what you need
is out there already? Yeah nah yeah. The projects you’re getting are getting bigger & more complex That awesome template (using first party tags/modules even) is generating 489 queries and taking 3 seconds to render. Things like LESS are crossing over into programming Good developers are always busy, pull some tasks over You want to learn Wednesday, 30 May 12 -
Designer to hybrid developer. The stages of evolution. @iain |
#EECI2012 EU Wednesday, 30 May 12 -
1.0 Awestruck Development is magic performed by gods. @iain |
#EECI2012 EU Wednesday, 30 May 12 -
2.0 Fumbling Idiot Coding by copy paste. @iain | #EECI2012
EU Wednesday, 30 May 12 -
3.0 Explorer A whole new world has opened up. @iain
| #EECI2012 EU Wednesday, 30 May 12 -
4.0 Delusional Intoxicated by new power. @iain | #EECI2012 EU
Wednesday, 30 May 12 -
5.0 Pragmatic Tools in your belt, experience to call upon.
You realise how much you don’t know. @iain | #EECI2012 EU Wednesday, 30 May 12 -
Be Realistic. You’re not moving to a new career, you’re
adding to your existing toolbelt. Some things are simply outside your reach. @iain | #EECI2012 EU Wednesday, 30 May 12 -
@iain | #EECI2012 EU Set some goals. Get to where
you want to be. Wednesday, 30 May 12 -
My Goals I set out to: @iain | #EECI2012 EU
Get some basic PHP skills Build some really simple, niche plugins Build a control panel module interface, with multiple views/methods Get data in and out of a database without using EE tags Be able to pinpoint problems (not necessarily solve them) Communicate my problems efficiently to outsource solutions Be less dependant on the EE dev team and take action myself for what I thought were the weak parts of EE Wednesday, 30 May 12 -
Fundamentals that make you go mental. @iain | #EECI2012 EU
Wednesday, 30 May 12 -
{exp:channel:entries limit="1" dynamic="off"
disable="custom|fields" } Think of a channel entries tag; We have a method, and we’re passing some parameters. @iain | #EECI2012 EU Wednesday, 30 May 12 -
@iain | #EECI2012 EU Lets take a simple PHP function:
http:/ /php.net/str_replace Wednesday, 30 May 12 -
{exp:str_replace search="Ellis Labs"
replace="EllisLab" subject="OH HAI Ellis Labs" } Here is our function/method with it’s available parameters echo str_replace( "Ellis Labs", "EllisLab", "OH HAI Ellis Labs" ); @iain | #EECI2012 EU Wednesday, 30 May 12 -
Here is our function/method with it’s available parameters http:/ /expressionengine.com/user_guide/development/reference/functions.html
$this-‐>EE-‐>functions-‐>word_limiter($my_words, 20); @iain | #EECI2012 EU Wednesday, 30 May 12 -
@iain | #EECI2012 EU Arrays. $entry = array(
"title" => "Street Fighter 2", "some_field" => "Some value" ); echo $entry["title"]; Think of variables that can store multiple values. Wednesday, 30 May 12 -
@iain | #EECI2012 EU Arrays. $entry = array(
"title" => "Street Fighter 2" "players" => array( "player_1" => "Blanka", "player_2" => "Dhalsim" ) ); echo $entry["players"]["player_1"]; Applying a “Matrix” concept to arrays. Wednesday, 30 May 12 -
@iain | #EECI2012 EU Arrays. $data = array(
"vendor" => "Bowers & Wilkins", "location" => "UK", "rating" => "9.5" ); $this-‐>EE-‐>db-‐>insert('vendors', $data); Once you understand them, you can start having fun. Wednesday, 30 May 12 -
@iain | #EECI2012 EU foreach loops Looping through arrays /
database results to make / get what you need Wednesday, 30 May 12 -
@iain | #EECI2012 EU Documentation & tutorials can only show
you so much. Use the source, Luke. Wednesday, 30 May 12 -
@iain | #EECI2012 EU Learn from EE itself: system/index.phpS=0&D=cp&C=admin_content&M=category_management Look
at your CP URL: /system/expressionengine/controllers/cp/admin_content.php We know what controller: function category_management()... And we know what method: Wednesday, 30 May 12 -
@iain | #EECI2012 EU Download Bamboo Invoice http:/ /bambooinvoice.org/ bamboo_system_files/application/controllers/
bamboo_system_files/application/models/ Wednesday, 30 May 12 -
@iain | #EECI2012 EU Get some SQL Fu. Learn how
EE stores it’s data Learn how to get what you need out of the database Wednesday, 30 May 12 -
@iain | #EECI2012 EU Get some SQL Fu. Look at
the Output Profiler, see what queries make up a page load Admin -> System Administration -> Output & Debugging Wednesday, 30 May 12 -
@iain | #EECI2012 EU Get some SQL Fu. Take a
shot at replicating some of EE’s tags using the query module Benchmark performance with your queries against EE’s tags - you might be surprised! {exp:query sql="SELECT title as the_title FROM exp_channel_titles WHERE site_id = '1' ORDER BY title ASC"} {the_title} <br /> {/exp:query} Wednesday, 30 May 12 -
@iain | #EECI2012 EU Open up and tinker with some
models in /system/expressionengine/models Wednesday, 30 May 12 -
@iain | #EECI2012 EU Form Helper Build your inputs http:/
/codeigniter.com/user_guide/helpers/form_helper.html <?php echo form_input('username'); ?> <input type="text" name="username" value="" /> Wednesday, 30 May 12 -
Input Class Access your post/get data and more. http:/ /codeigniter.com/user_guide/libraries/input.html
@iain | #EECI2012 EU $username = $this-‐>EE-‐>input-‐>post('username'); Wednesday, 30 May 12 -
Active Record Class Retrieve, insert, and update data in your
database with minimal scripting. http:/ /codeigniter.com/user_guide/database/active_record.html @iain | #EECI2012 EU $data = array( "name" => $this-‐>EE-‐>input-‐>post('username'), "email" => $this-‐>EE-‐>input-‐>post('email') ); $this-‐>EE-‐>db-‐>insert('people', $data); Wednesday, 30 May 12 -
Check how EllisLab do it. @iain | #EECI2012 EU =>
$this-‐>input-‐>post( Search the EE code base for: Wednesday, 30 May 12 -
@iain | #EECI2012 EU On our way. We’ve got our
heads around basic php functions, and things like arrays. We’re understanding documentation more We’re looking at the source, and know where to look when we want to see what’s happening under the bonnet We’re getting to grips with how EE stores it’s data Wednesday, 30 May 12 -
HELP. @iain | #EECI2012 EU EE forums - sometimes *crickets*,
sometimes extremely useful. Follow up with a #eecms tagged tweet with a link to your post. StackOverflow - when you’ve broken problem down to specifics Trawl other add-ons - be careful here Give it a shot, try as best you can. Developers generally see through lazyness and get annoyed with “someone do it for me” type questions. Extract the problem from the bigger picture. Break it down into it’s smallest parts. Step away from the keyboard. Come back later the solution is clear. Wednesday, 30 May 12 -
Handling clients When you feel like you’re out your depth:
@iain | #EECI2012 EU Its ok to say “I don’t know, but I will find out for you” Your biggest strength is your understanding of the problem Don’t just keep track of your hours and pass the bill to the client - charge fairly Start with the must have features, and scale into it Get your client on-board, be honest. Trust your gut, early warnings especially Wednesday, 30 May 12 -
@iain | #EECI2012 EU Going forward Have a sense of
humour. You will find your own code funny in the following weeks and months. Don’t bag other people’s work. Have respect. Throw your stuff out there, get it on GitHub. Announce it on Twitter - don’t be scared. You get to a tipping point where things start ‘sticking’. It just takes time. Have thick skin - don’t be put off learning when someone calls you out, or has a go. Wednesday, 30 May 12 -
If your old code isn't bad, you haven't learned anything
since you wrote it. @iain | #EECI2012 EU — Unkown Wednesday, 30 May 12