SunShop Modifications Part 6

In this sec­tion we look at my cache mech­a­nism. It’s sim­i­lar in prin­ci­ple to the Word­Press “tran­sient” con­cept. For exam­ple, the “top sell­ers in the last 30 days” does not need to be cal­cu­lated every page load. Cal­cu­lat­ing once per hour should be more than suf­fi­cient. Doing both cal­cu­la­tions (all time best sell­ers and best sell­ers last 30 days) takes 1–4 sec­onds depend­ing on server load, and the Top Sell­ers page turns out to be one of the most pop­u­lar pages. It is there­fore a good can­di­date for caching.

I also found that a lot of the border/navigation items take a long time to gen­er­ate, and again are good can­di­dates for caching. Within Sun­Shop we make all sorts of lists for nav­i­ga­tion pur­poses, every page load, and then never use much of the result. With caching, I reduced the hun­dreds of queries per page load down to a dozen or so.

For exam­ple, if it takes a hun­dred queries to build up a sorted list, and we can safely cache the result for an hour or so, we have a huge page-performance gain. Why so many queries? In cer­tain cases, Sun­Shop does one query to get a sorted list of item IDs, and then loops through the list doing a sep­a­rate query for each item in the list.

We’ll use the Top Sell­ers plu­gin as our use case. We cache the result of each top sell­ers cal­cu­la­tion for 60 min­utes. Read more…

Be the first to comment - What do you think?  Posted by admin - March 1, 2013 at 10:16 pm

Categories: PHP/MySQL Tutorials   Tags:

SunShop Modifications Part 5

In this sec­tion we look at my Top Sell­ers plu­gin. This gives us a con­crete exam­ple of writ­ing a plu­gin. How­ever, with this exam­ple we’ll use my full plu­gin “frame­work” which includes my Reg­is­tered Object mech­a­nism. We’ll also see my persistent-cache mech­a­nism in use, which we’ll then explore in a later post.

Top Sell­ers Plu­gin Invocation

We invoke the two plu­g­ins as fol­lows, in the Top Sell­ers page tem­plate. We use “bb_” as the pre­fix to avoid name­space col­li­sions: Read more…

Be the first to comment - What do you think?  Posted by admin - at 9:27 pm

Categories: PHP/MySQL Tutorials   Tags:

SunShop Modifications Part 4

Here in Part 4 I show another tech­nique which I use to keep my cus­tom code off to the side. I’m no longer a fan of the Sin­gle­ton Design Pat­tern because of its dif­fi­culty in unit test­ing. How­ever, it’s a good tool for Sun­Shop modifications.

Our Top Sell­ers page has two tabs, one tab for All time top sell­ing prod­ucts, and another tab for top sell­ers over the past 30 days. I use “bb_” as my pre­fix to ensure no name­space col­li­sions. Here is the page tem­plate: Read more…

Be the first to comment - What do you think?  Posted by admin - at 8:34 pm

Categories: PHP/MySQL Tutorials   Tags:

SunShop Modifications Part 3

In this sec­tion we look at one of my cus­tom Sun­Shop pages, the SEO list. I’m assum­ing you have access to a Sun­Shop admin area, and you know what an admin page looks like. Visit the Sun­Shop Offi­cial Demo Page here to fol­low along if you need to.

The Cus­tomiza­tion

As part of our SEO (Search Engine Opti­miza­tion) work, we are exam­in­ing all prod­uct descrip­tions, short descrip­tions, meta descrip­tions, sam­ple text, etc. I wrote code for the Edit Prod­uct page which cre­ates a prod­uct pre­view, a Google-listing sim­u­la­tion, etc., with the tar­get search terms highlighted.

In order to high­light the search terms, nat­u­rally, we need to know the list of tar­get search terms. This quick-and-simple admin page allows us to enter each search term, its rel­a­tive pri­or­ity (1, 2, 3, etc.) on our list, and a CSS class defin­ing the high­light color. You will recall our page sup­port looks like this: Read more…

Be the first to comment - What do you think?  Posted by admin - at 6:21 pm

Categories: PHP/MySQL Tutorials   Tags:

SunShop Modifications Part 2

In Part 2 I explain how to get the code mod­i­fi­ca­tions off to the side. We start by explain­ing why this is important.

Why We Need to Get Our Code Off To The Side

Sun­Shop is actively sup­ported soft­ware under active devel­op­ment. That means your Sun­Shop instal­la­tion could, at some point, be upgraded to a new soft­ware release. That gen­er­ally means you lose your cus­tom mod­i­fi­ca­tions — unless they are com­pletely sep­a­rate from the main­line code.

The Sun­Shop instal­la­tion instruc­tions explain how to do this with the template/css/javascript files: Copy your pre­ferred theme tem­plates to a new folder and do your tem­plate mod­i­fi­ca­tions in the new folder. This way, when the soft­ware is upgraded and the stan­dard tem­plate folder is replaced, your tem­plate files will not be overwritten.

Since this “Sun­Shop Mod­i­fi­ca­tions” series is aimed at PHP devel­op­ers, not tweak­ing tem­plates, that’s all I have to say about man­ag­ing the tem­plate files!

Sun­Shop Admin Area Enhancements

My gen­eral strat­egy for the Sun­Shop Admin Area is to cre­ate a new admin page. This doesn’t always work, for exam­ple, I added some addi­tional fields to the Edit Prod­uct page. The best I could do in this case is add my name and date as a com­ment, so that I can search on my own name when it comes time to upgrade the software.

My cus­tom admin page sup­port looks like this: Read more…

Be the first to comment - What do you think?  Posted by admin - at 6:10 pm

Categories: PHP/MySQL Tutorials   Tags:

SunShop Modifications Part 1

The Sun­Shop soft­ware is a com­mer­cial prod­uct from Turnkey Web Tools. These tuto­ri­als do NOT expose any orig­i­nal Sun­Shop code, only my own code.

The Project

My client com­mis­sioned me to make cus­tom cart mod­i­fi­ca­tions to Sun­Shop. I am shar­ing source code with my client’s per­mis­sion. The mod­i­fi­ca­tions include:

  • Feature/bug fixes
  • New func­tion­al­ity aimed at enhanc­ing the user experience
  • SEO work (Search Engine Opti­miza­tion) based on a consultant’s rec­om­men­da­tions and my own rec­om­men­da­tions. This became a num­ber of areas includ­ing page load time, addi­tional text, and lay­out changes. Read more…

Be the first to comment - What do you think?  Posted by admin - at 1:49 pm

Categories: PHP/MySQL Tutorials   Tags:

How to install Perl CPAN Modules Offline

I have a sit­u­a­tion where I’m able to down­load a CPAN mod­ule dis­tri­b­u­tion, but I’m behind a fire­wall and I there­fore can’t install the mod­ule using the cpan installer. The rec­om­mended offline solu­tion is to use the CPAN Mini Mir­ror. But that presents the same prob­lem: It expects to have Inter­net access.

The solu­tion is sim­ple — don’t use the CPAN installer! Just do the Make­file your­self. Here is how I installed the Test::Class mod­ule:

tar xzf Test-Class-0.37.tar.gz
cd Test-Class-0.37
perl Makefile.PL
make
make test
make install

If you can’t do it the easy way, don’t for­get you can do it the “Old School” way!

Be the first to comment - What do you think?  Posted by admin - September 26, 2012 at 10:49 am

Categories: Perl Webmastery   Tags:

WordPress NextGEN Gallery Tips and Tricks

My son Jakob Barnard rec­om­mended the NextGEN plu­gin for Word­Press. If you’re pressed for time in learn­ing to use it, I rec­om­mend you find a tuto­r­ial via Google. I found

The Word­Press Ninja tuto­r­ial gave me a great overview of what the work­flow is in set­ting up a gallery. The video tuto­r­ial was well worth the addi­tional 12 min­utes. The author takes the time to gen­er­ate errors and show how you see what is going wrong. Very helpful!

Hav­ing just put up my own first NextGEN gallery, I have addi­tional tips for you.

Fix For NextGEN Gallery Slide Show Not Working

A google search showed numer­ous com­plains that the Slide Show fea­ture was not work­ing. Answers included con­flict­ing plu­g­ins and Go Daddy host­ing. My solu­tion was quite sim­ple: Work your way through all of the NextGEN set­tings! I’ve got­ten spoiled by all the great plu­g­ins out there and have begun to expect every­thing to work well enough “out of the box.” Wrong answer! Read more…

Be the first to comment - What do you think?  Posted by admin - September 21, 2012 at 6:00 am

Categories: Genealogy Webmaster's Journal   Tags: , ,

Multiple Backups with Apple Mac OS X Time Machine

I find Apple’s Time Machine backup sys­tem to extremely annoy­ing. After five years, it finally paid off!

Hard Drive Fail­ures Do Happen

To be sure, when my Mac­Book hard drive failed four years ago, restor­ing from backup was extremely easy. Get­ting the hard drive replaced was, in the­ory, easy. I went to the Apple store at the Mall of Amer­ica and they replaced it under war­ranty. Unfor­tu­nately this was the same week­end the iPhone 3G was released. We spent all day wait­ing for the hard drive replacement!

But once I got my Mac­Book home, I plugged in the backup hard drive, which is main­tained by the Time Machine backup sys­tem, and it restored every­thing from there. I lost up to four hours’ worth of email, but absolutely every­thing else was pre­served. Nice!

How does Time Machine work and why do I find it so annoy­ing? Read more…

Be the first to comment - What do you think?  Posted by admin - September 20, 2012 at 6:00 am

Categories: Genealogy Webmaster's Journal   Tags: , , ,

Quick Fix For Atahualpa Theme Sticky Posts

Today I upgraded the The Strong Fam­ily Asso­ci­a­tion of Amer­ica, Inc. theme. I use Atahualpa, and it’s been years since I updated the theme. I needed to move my fav­i­con and logo from theme folder atahualpa333 to atahualpa. For­tu­nately, the theme car­ried my options for­ward to the new version.

Here is a hint: Turn on Fire­bug and let it tell you what images are bro­ken or missing!

I found that the sticky note graphic was miss­ing. Here is the fix: Go to the Atahualpa theme options. Click on the sec­tion Style POSTS & PAGES. The sec­ond sec­tion is POST Con­tainer: STICKY. There is a space in the back­ground image url. For my site, it reads:

back­ground: #eee url(‘http://strongfamilyofamerica.org/wp-content/themes/atahualpa /images/sticky.gif’) 99% 5% no-repeat;

Whereas it should read:

back­ground: #eee url(‘http://strongfamilyofamerica.org/wp-content/themes/atahualpa/images/sticky.gif’) 99% 5% no-repeat;

The prob­lem is that pesky space after atahualpa and before /images/sticky.gif. Remove the space, save your set­tings, and you’re good!

Be the first to comment - What do you think?  Posted by admin - September 19, 2012 at 6:00 am

Categories: Genealogy Webmaster's Journal   Tags: ,

Next Page »