Most websites I work on these days have some sort of header image on almost every page - an optional “banner” if you will, that adds to the general feel of the current section of the site. Since most of these sites as also managed through a CMS setup (symfony, sfDynamicCMS + custom stuff) it is a requirement to be able to adjust these images on a per-page level, even though most pages share the same image within their section..
In short, we often have a need for flexible customization without putting the user through the nightmare of picking a picture through the admin interface every time they want to create a page.
The solution we came up with is rather simple, yet so elegant that we found it to work in all our sites - we use a storage convention based on the page URL.
For example, let’s take a page with the following url:
http://www.somesite.com/sports/outdoors/hiking
where “sports” and “outdoors” are categories, and “hiking” is a specific activity.
The required flexibility now is that the we wanted to be able to have a base-banner for the “sports” section, be able to (optionally) override this for each sub-category, and for each specific activity. As you can see, mapping the url to a directory in the webroot and working backwards would yield just that nice cascade.
Say for example we needed a banner on said page, we would want to look for the following images (in this order):
"/uploads/banner/sports/outdoors/hiking.jpg" "/uploads/banner/sports/outdoors.jpg" "/uploads/banner/sports.jpg" "/uploads/banner.jpg"
Whichever picture is found first, wins.
We add the “banner” directory to be able to pull the same trick for other assets.. maybe a product manual, or a particular flash file for the footer? Never limit your options..
Now, the code that does this cascading lookup based on url is fairly trivial, but I wanted the whole thing to be very intuitive and simple for our front-end guys, so that they can easily use this functionality from within templates. Turns out this is a perfect case for the ArrayAccess interface, which allows you to access objects via array syntax.
The resulting template code looks as simple as:
$image = $assets["banner"];
and you we even let you specify the file type via an optional extension (defaults to JPG):
$image = $assets["banner.png"]; $document = $assets["manual.pdf"]; $audio = $assets["music.swf"];
As you can see, this setup makes it very easy to distribute general and specific assets throughout your site and administering the files via a wysiwyg or standalone asset manager - without cluttering up the admin area.
Hope you’ll find this as time-saving and elegant as I find it.
Have a great day,
Daniel
Pillspot.org. Canadian Health&Care.Special Internet Prices(up to 40% off average US price).No prescription online pharmacy.Pillspot.org. Vitamins@buy.online” rel=”nofollow”>.…
Categories: Stop SmokingSkin Care.Anti-allergic/Asthma.Antidepressants.Womens Health.Pain Relief.Antidiabetic.Weight Loss.Eye Care.Anxiety/Sleep Aid.Mens Health.Cholesterol.Stomach.Antibiotics.Mental Health/Epilepsy.Antiviral.Blood Pressure/Heart….
Trackback by ENRIQUE — June 25, 2010 @ 4:00 am
Buy:Female Pink Viagra.Zocor.Ventolin.Buspar.Nymphomax.Benicar.Prozac.Lasix.Lipitor.Lipothin.Acomplia.Amoxicillin.Female Cialis.Cozaar.SleepWell.Seroquel.Aricept.Wellbutrin SR.Zetia.Advair….
Trackback by ERIK — July 21, 2010 @ 4:58 am
ives http://sstgzq13j.bestpartsstore.info/tag/r2+stress+ives/ : ives…
stress…
Trackback by stress — August 29, 2010 @ 3:10 am
boot http://xspotcwp.bestpartsstore.info/tag/oakley+Ski+boot/ : oakley…
Ski…
Trackback by boot — August 29, 2010 @ 2:19 pm
halotone http://yphilipsom0.ACEHARDWAREE.INFO/tag/halotone+Light+philips/ : Light…
philips…
Trackback by philips — August 29, 2010 @ 6:03 pm
Buy:Prednisolone.Petcam (Metacam) Oral Suspension.Zovirax.Human Growth Hormone.Actos.Lumigan.Retin-A.Synthroid.100% Pure Okinawan Coral Calcium.Nexium.Mega Hoodia.Zyban.Accutane.Arimidex.Prevacid.Valtrex….
Trackback by ALLEN — September 5, 2010 @ 9:40 am
Buy:Super Active ED Pack.Tramadol.Cialis Professional.Viagra Super Active+.Cialis.Viagra.Soma.Viagra Professional.Zithromax.VPXL.Cialis Super Active+.Maxaman.Propecia.Levitra.Viagra Soft Tabs.Cialis Soft Tabs.Viagra Super Force….
Trackback by MATT — September 6, 2010 @ 6:00 am
Air http://ttd.bz5.ii99.co : Home…
Home…
Trackback by Air — September 14, 2010 @ 7:56 pm
…
BUY FASHION. TOP BRANDS: GUCCI, DOLCE&GABBANA, BURBERRY, DIESEL, ICEBERG, ROBERTO CAVALLI, EMPORIO ARMANI, VERSACE…
Trackback by HAROLD — November 10, 2010 @ 6:24 pm
████████►BUY CIALIS◀████████…
▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲…
Trackback by CHARLIE — December 18, 2010 @ 11:26 am
abilify side effects in children…
Buydrugs without prescription…
Trackback by LONNIE — December 20, 2010 @ 9:04 am
dosage of amoxicillin for respiratory disorder…
Buygeneric drugs…
Trackback by TIMOTHY — December 22, 2010 @ 10:16 am
Abilify…
Buygeneric meds…
Trackback by TERRANCE — December 24, 2010 @ 4:23 am
rxlist@abilify.now” rel=”nofollow”>..…
Buydrugs without prescription…
Trackback by ANTHONY — December 25, 2010 @ 7:36 am
fosamax@actonel.now” rel=”nofollow”>.…
Buynow…
Trackback by RICARDO — December 27, 2010 @ 11:41 pm
Advair@official.site” rel=”nofollow”>.…
Buynow it…
Trackback by EUGENE — December 28, 2010 @ 12:53 pm
Amoxicillin@official.site” rel=”nofollow”>……
Buyno prescription…
Trackback by FERNANDO — December 29, 2010 @ 5:10 pm
Ampicillin@official.site” rel=”nofollow”>.…
Buynow it…
Trackback by KELLY — December 30, 2010 @ 7:04 am
..…
Buygeneric drugs…
Trackback by LARRY — December 30, 2010 @ 10:52 pm
Azor@official.site” rel=”nofollow”>……
Buygeneric pills…
Trackback by GREGORY — December 31, 2010 @ 5:40 am
Augmentin@official.site” rel=”nofollow”>.…
Buywithout prescription…
Trackback by ALBERTO — January 1, 2011 @ 4:50 am
Clonidine@official.site” rel=”nofollow”>……
Buynow…
Trackback by RICK — January 1, 2011 @ 1:23 pm
generic@viagra.sildenafil.paypal.no.prescription” rel=”nofollow”>……
Buygeneric meds…
Trackback by DARRELL — January 4, 2011 @ 9:39 am
abilify@and.sleep.issues” rel=”nofollow”>.…
Buyno prescription…
Trackback by GUY — January 5, 2011 @ 11:43 am
……
Buynow it…
Trackback by BRETT — January 7, 2011 @ 5:56 pm
Abilify@official.site” rel=”nofollow”>……
Buynow…
Trackback by DOUGLAS — January 16, 2011 @ 11:52 pm
Abilify@official.site” rel=”nofollow”>……
Buynow it…
Trackback by HUBERT — January 17, 2011 @ 3:05 am
Depakote@official.site” rel=”nofollow”>.…
Buygeneric drugs…
Trackback by DENNIS — January 21, 2011 @ 4:59 am
lisinopril aspirin interaction…
Buywithout prescription…
Trackback by MARK — February 3, 2011 @ 4:05 am
what is the shelf life of zyrtec…
Buynow it…
Trackback by MATTHEW — February 4, 2011 @ 10:40 am
Zocor…
Buygeneric meds…
Trackback by CLINTON — February 5, 2011 @ 12:03 am
other names for trazodone…
Buyno prescription…
Trackback by ARTHUR — February 5, 2011 @ 11:44 pm
quinapril…
Buyit now…
Trackback by LONNIE — February 6, 2011 @ 2:30 pm
dog zyrtec…
Buygeneric drugs…
Trackback by REGINALD — February 6, 2011 @ 8:34 pm
Zocor…
Buygeneric drugs…
Trackback by NEIL — February 7, 2011 @ 2:48 am
Vytorin…
Buynow…
Trackback by STUART — February 7, 2011 @ 7:28 am
Vitamin B…
Buydrugs without prescription…
Trackback by KARL — February 7, 2011 @ 10:02 am
Zofran…
Buygeneric pills…
Trackback by RUSSELL — March 3, 2011 @ 1:09 am
Zyprexa…
Buydrugs without prescription…
Trackback by CHAD — March 4, 2011 @ 4:59 am
Rogaine…
Buygeneric meds…
Trackback by CHRIS — March 4, 2011 @ 8:01 pm
Pain Balm…
Buyno prescription…
Trackback by RANDALL — March 6, 2011 @ 7:04 pm
Orlistat…
Buyit now…
Trackback by CHRISTIAN — March 6, 2011 @ 7:22 pm
Eye Drops…
Buynow…
Trackback by RAFAEL — March 6, 2011 @ 10:31 pm
Risperdal…
Buygeneric meds…
Trackback by STEVEN — March 7, 2011 @ 11:01 am
Prozac…
Buyno prescription…
Trackback by HUBERT — March 8, 2011 @ 4:31 am
howard county purim carnival 2010…
Buyno prescription…
Trackback by TERRANCE — March 8, 2011 @ 10:45 pm
how much benadryl to take with zyrtec…
Buydrugs without prescription…
Trackback by OTIS — March 9, 2011 @ 3:46 am
Risperdal…
Buygeneric pills…
Trackback by AARON — March 9, 2011 @ 10:23 am
savella cheap canada…
Buyno prescription…
Trackback by JULIO — March 9, 2011 @ 10:37 pm
Rogaine…
Buygeneric meds…
Trackback by CHRIS — March 10, 2011 @ 10:24 am
low dose haldol and paxil…
Buygeneric drugs…
Trackback by ROBERTO — March 10, 2011 @ 9:38 pm
Zoloft…
Buynow it…
Trackback by CURTIS — March 28, 2011 @ 8:31 pm
Synthroid@Synthroid.Synthroid” rel=”nofollow”>.…
Buynow it…
Trackback by JULIO — March 28, 2011 @ 9:19 pm
Tri@Cyclen.now” rel=”nofollow”>……
Buyno prescription…
Trackback by CLAUDE — March 29, 2011 @ 5:07 am
Soma@Soma.Soma” rel=”nofollow”>.…
Buyno prescription…
Trackback by GEORGE — March 29, 2011 @ 1:20 pm
Purim@Purim.Purim” rel=”nofollow”>……
Buygeneric drugs…
Trackback by SAM — March 30, 2011 @ 6:46 am
Singulair@Singulair.Singulair” rel=”nofollow”>……
Buygeneric pills…
Trackback by EDGAR — March 30, 2011 @ 3:55 pm
Prozac@Prozac.Prozac” rel=”nofollow”>.…
Buygeneric pills…
Trackback by TYRONE — March 30, 2011 @ 4:58 pm
Provera@Provera.Provera” rel=”nofollow”>.…
Buygeneric pills…
Trackback by GREGORY — March 30, 2011 @ 6:40 pm
Cipro@Cipro.Cipro” rel=”nofollow”>..…
Buygeneric meds…
Trackback by JOSHUA — March 31, 2011 @ 7:48 am
Singulair@Singulair.Singulair” rel=”nofollow”>.…
Buygeneric drugs…
Trackback by SEAN — March 31, 2011 @ 7:53 am
cms@coverage.of.pulmicort.respules.j7627” rel=”nofollow”>.…
Buygeneric pills…
Trackback by SHAUN — April 1, 2011 @ 4:18 pm
dapple@hydrocortisone.cream” rel=”nofollow”>……
Buyit now…
Trackback by DENNIS — April 1, 2011 @ 8:23 pm
……
Buywithout prescription…
Trackback by DONALD — April 2, 2011 @ 2:19 am
allegra@print.colorado.springs” rel=”nofollow”>……
Buygeneric drugs…
Trackback by MANUEL — April 2, 2011 @ 8:13 am
buy@acai.berry.supplement” rel=”nofollow”>.…
Buyit now…
Trackback by KURT — April 3, 2011 @ 5:00 am
accutane@and.ototoxicity” rel=”nofollow”>……
Buyno prescription…
Trackback by WAYNE — April 3, 2011 @ 7:19 am
.…
Buyno prescription…
Trackback by GEORGE — April 3, 2011 @ 4:18 pm
alternatives@to.premarin” rel=”nofollow”>……
Buygeneric pills…
Trackback by KIRK — April 4, 2011 @ 9:16 am
altace@generic.name” rel=”nofollow”>.…
Buynow it…
Trackback by ADRIAN — April 4, 2011 @ 8:28 pm
.…
Buygeneric drugs…
Trackback by HARRY — April 5, 2011 @ 12:21 am
coral@calcium.safety” rel=”nofollow”>.…
Buyit now…
Trackback by REX — April 5, 2011 @ 8:41 am
abilify@does.it.work” rel=”nofollow”>.…
Buynow it…
Trackback by JEROME — April 6, 2011 @ 12:01 am
flexeril@gain.weight” rel=”nofollow”>.…
Buygeneric drugs…
Trackback by HARVEY — April 6, 2011 @ 12:33 am
calories@and.nutrition.in.boost.nutritional.energy.drink” rel=”nofollow”>……
Buywithout prescription…
Trackback by EDDIE — April 6, 2011 @ 6:32 am
……
Buygeneric drugs…
Trackback by JAIME — April 6, 2011 @ 12:49 pm
multiple@myeloma.gleevec.clinical.trials” rel=”nofollow”>.…
Buynow it…
Trackback by ADRIAN — April 7, 2011 @ 12:05 am
buy@generic.LEVITRA” rel=”nofollow”>……
Need cheap generic LEVITRA?…
Trackback by Alexander7 — July 22, 2011 @ 6:54 pm
Get@Coral.Calcium.Online” rel=”nofollow”>..…
Buygeneric drugs…
Trackback by DUSTIN — July 29, 2011 @ 2:05 am
Order@Abana.Online” rel=”nofollow”>……
Buywithout prescription…
Trackback by PERRY — July 29, 2011 @ 3:44 am
Buy@Discount.Acai” rel=”nofollow”>..…
Buynow it…
Trackback by CHARLIE — July 30, 2011 @ 3:54 am
Buy@Generic.Acai.Without.Prescription” rel=”nofollow”>……
Buygeneric drugs…
Trackback by WALLACE — July 30, 2011 @ 10:02 pm
Cheap@Abana.Online” rel=”nofollow”>..…
Buyno prescription…
Trackback by BRANDON — August 1, 2011 @ 5:44 am
Purchase@Generic.Abilify” rel=”nofollow”>.…
Buynow it…
Trackback by ENRIQUE — August 1, 2011 @ 1:40 pm
Order@Coral.Calcium.Online” rel=”nofollow”>..…
Buynow it…
Trackback by LEWIS — August 2, 2011 @ 12:11 am
Get@Abana.Online” rel=”nofollow”>..…
Buyit now…
Trackback by TERRENCE — August 2, 2011 @ 10:53 am
Order@Abilify.Online” rel=”nofollow”>..…
Buygeneric pills…
Trackback by EDUARDO — August 2, 2011 @ 9:20 pm
Buy@Generic.Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>..…
Buygeneric meds…
Trackback by TRACY — August 3, 2011 @ 7:42 am
Buy@Acai.Online” rel=”nofollow”>.…
Buywithout prescription…
Trackback by KURT — August 3, 2011 @ 11:24 am
Order@Cheap.Acai” rel=”nofollow”>……
Buyit now…
Trackback by FELIX — August 3, 2011 @ 5:25 pm
Order@Discount.Acai” rel=”nofollow”>……
Buyit now…
Trackback by DONALD — August 3, 2011 @ 7:23 pm
Order@Generic.Acai” rel=”nofollow”>..…
Buydrugs without prescription…
Trackback by JACK — August 4, 2011 @ 2:06 pm
Buy@Accupril.Online” rel=”nofollow”>.…
Buygeneric meds…
Trackback by CARL — August 5, 2011 @ 9:54 am
Purchase@Accutane.Without.Prescription” rel=”nofollow”>.…
Buygeneric drugs…
Trackback by BILLY — August 6, 2011 @ 3:55 pm
Buy@Generic.Aciphex.20mg” rel=”nofollow”>.…
Buynow it…
Trackback by BYRON — August 8, 2011 @ 12:38 pm
Buy@Actonel.35mg” rel=”nofollow”>..…
Buygeneric drugs lzt…
Trackback by RODNEY — August 10, 2011 @ 3:50 pm
Buy@Actos.Online” rel=”nofollow”>.…
Buygeneric drugs zfk…
Trackback by RAY — August 11, 2011 @ 1:18 am
Buy@Generic.Actos” rel=”nofollow”>..…
Buygeneric drugs eet…
Trackback by BRANDON — August 11, 2011 @ 10:39 am
Buy@Generic.Actos.Without.Prescription” rel=”nofollow”>..…
Buygeneric drugs krg…
Trackback by DARYL — August 11, 2011 @ 11:42 am
Order@Adalat.Online” rel=”nofollow”>..…
Buygeneric meds qhr…
Trackback by ALEJANDRO — August 12, 2011 @ 10:36 am
Buy@Generic.Abilify.Without.Prescription” rel=”nofollow”>..…
Buygeneric pills zdg…
Trackback by VICTOR — August 13, 2011 @ 10:08 am
Cheap@Generic.Abilify.5mg.10mg.15mg.20mg.30mg” rel=”nofollow”>.…
Buywithout prescription yyn…
Trackback by TIM — August 13, 2011 @ 6:38 pm
Buy@Acai.Online” rel=”nofollow”>……
Buydrugs without prescription vrg…
Trackback by JERRY — August 13, 2011 @ 10:11 pm
Order@Energy.Boost.Online” rel=”nofollow”>.…
Buygeneric drugs axm…
Trackback by LEWIS — August 15, 2011 @ 8:37 am
Cheap@Energy.Boost.Online” rel=”nofollow”>……
Buydrugs without prescription jlg…
Trackback by BRETT — August 15, 2011 @ 3:12 pm
Get@Energy.Boost.Online” rel=”nofollow”>..…
Buyno prescription jui…
Trackback by BRUCE — August 15, 2011 @ 4:18 pm
Buy@Aciphex.20mg” rel=”nofollow”>.…
Buygeneric drugs mby…
Trackback by MARION — August 19, 2011 @ 12:12 am
Purchase@Generic.Aciphex.20mg” rel=”nofollow”>……
Buywithout prescription ccw…
Trackback by JASON — August 19, 2011 @ 2:40 am
Order@Cheap.Advair” rel=”nofollow”>……
Buygeneric drugs vbr…
Trackback by CARLOS — August 22, 2011 @ 10:21 pm
Order@Generic.Advair” rel=”nofollow”>..…
Buydrugs without prescription hak…
Trackback by RAUL — August 23, 2011 @ 3:40 pm
Buy@Albenza.Online” rel=”nofollow”>.…
Buyit now ojb…
Trackback by MARVIN — August 25, 2011 @ 4:26 am
Order@Albenza.Online” rel=”nofollow”>..…
Buydrugs without prescription faj…
Trackback by HARVEY — August 25, 2011 @ 8:24 am
Purchase@Discount.Albenza” rel=”nofollow”>……
Buynow fjl…
Trackback by BILLY — August 25, 2011 @ 3:03 pm
Buy@Aldactone.Online” rel=”nofollow”>.…
Buygeneric drugs hwi…
Trackback by SHANE — August 25, 2011 @ 7:05 pm
aloe@vera.juice.benefits.best” rel=”nofollow”>.…
Buygeneric meds…
Trackback by ALBERTO — August 27, 2011 @ 9:27 am
hiv research being conducted in usa…
Buy_generic pills…
Trackback by BRANDON — October 16, 2011 @ 8:53 pm
advair and contraindications…
Buy_generic meds…
Trackback by FREDDIE — October 18, 2011 @ 6:57 pm
canine heat cycles…
Buy_without prescription…
Trackback by MICHAEL — October 18, 2011 @ 8:38 pm
apo amitriptyline…
Buy_generic pills…
Trackback by ALBERTO — October 19, 2011 @ 10:59 pm
conquer online hacking tools…
Buy_generic drugs…
Trackback by ALFREDO — October 21, 2011 @ 7:11 am
symptoms of prescription drug abuse…
Buy_drugs without prescription…
Trackback by KYLE — October 21, 2011 @ 12:10 pm
working and twin pregnancy…
Buy_now it…
Trackback by MANUEL — October 26, 2011 @ 1:50 pm
how to embed pictures ms office…
Buy_drugs without prescription…
Trackback by FRANCIS — October 27, 2011 @ 4:53 am
adult survivors of childhood cancer…
Buy_generic pills…
Trackback by RAMON — October 28, 2011 @ 5:49 am
singapore secure psychiatric forensic unit…
Buy_no prescription…
Trackback by DOUGLAS — October 28, 2011 @ 11:29 pm
mini insulin fridge…
Buy_generic drugs…
Trackback by ALFREDO — October 29, 2011 @ 9:24 am
cheap fetal heart rate monitor…
Buy_generic meds…
Trackback by TOM — October 29, 2011 @ 9:03 pm
avelox treats for bacteria…
Buy_drugs without prescription…
Trackback by ANDREW — October 30, 2011 @ 4:34 am
drug treatment for bipolar disorder…
Buy_generic pills…
Trackback by SERGIO — October 30, 2011 @ 11:08 am
build muscle mass diet…
Buy_drugs without prescription…
Trackback by ROSS — November 5, 2011 @ 12:18 pm
free diabetes logbooks to print…
Buy_generic drugs…
Trackback by LUTHER — November 8, 2011 @ 10:51 pm
hiv quality of life survey tools…
Buy_drugs without prescription…
Trackback by DAVE — November 10, 2011 @ 6:31 am
obesity in moorhead minnesota…
Buy_now…
Trackback by PATRICK — November 10, 2011 @ 11:32 am
kim kardashian weight gain…
Buy_now…
Trackback by IVAN — November 12, 2011 @ 5:12 am
breast cancer site is having trouble…
Buy_drugs without prescription…
Trackback by JORGE — November 12, 2011 @ 10:11 am
boost metabolism foods…
Buy_now…
Trackback by JIM — November 15, 2011 @ 10:09 am
substitute for diovan hct…
Buy_now…
Trackback by GARY — November 16, 2011 @ 2:28 pm
Download@alternative.Rock” rel=”nofollow”>.…
Search rock UK Charts…
Trackback by nathaniel — December 10, 2011 @ 3:51 pm