Posts

Link to a Specific jQuery Tab

I was searching for a way to link to a specific tab on one page from another. My initial process was to add a check to my JavaScript to see if a parameter was passed to the page containing the tab I wanted. I actually ran the site like this for over a month before I learned that jQuery has already through about this issue and provided a solution.

Let's say you have the following layout for a set of tabs:

<div class="tabs">
    <ul>
        <li><a href="#tab-1">Tab 1</a></li>
        <li><a href="#tab-2">Tab 2</a></li>
        <li><a href="#tab-3">Tab 3</a></li>
        <li><a href="#tab-4">Tab 4</a></li>
    </ul>
    <div id="tab-1">Tab 1 Content</div>
    <div id="tab-2">Tab 2 Content</div>
    <div id="tab-3">Tab 3 Content</div>
    <div id="tab-4">Tab 4 Content</div>
</div>

Really standard I know but still helpful.

I need to direct the user to the second tab to act on some important piece of information. I could ask them to do this or I could add #tab-2 to the end of the url for the page to direct them to the correct tab automatically.

<a href="/path/to/file.php#tab-2">Click here 
to see some important information!</a>

Node.js Discussion on FLOSS Weekly

I have a love/hate relationship with FLOSS Weekly. On one hand they provide an excellent podcast that provides information on a lot of FLOSS software but on the other they create a bunch of potential experiments for me. :-)

I just listened to the interview they did with Matt Ranney about Node.js. Matt provided a really excellent rundown of why someone would want to try using Node.js and it's made me want to try it. The thing I find most interesting about the Node.js platform is that it's just running Javascript which means you don't have to learn another language (if you already know JS). They also claim that it has excellent performance due to the event driven nature of the platform.

I would highly recommend watching/listening to the podcast for more information:

http://twit.tv/show/floss-weekly/237

Zend_Form's 'Missing' getRequired Function

On one of the site's I've been working on for a client I wanted to add the word '(Required)' to the label of any element that was set to required. I assumed that because the function that sets this requirement is setRequired that getRequired would be the function to get it's value. I was surprised to find this error message:

[code]
Method getRequired does not exist
[/code]

It turns out that the function I was looking for was isRequired(). I'm sure other people will have the same problem so hopefully this helps.

Quick Tip: Helping to Troubleshoot View Scripts

I've spent a lot of time creating views recently (I don't even want to count how many) and with the large numbers of partials we use some times it's confusing what scripts are being included where.  To combat this problem I've started adding the page to the view file at the top of the view file so it's easier to track down.  It adds weight to the page size but I think it's worth it.

[code language="html"]

[/code]

Changing Hosts

The host that I was using to host this blog decided last month (or at least I was told last month) to stop offering the VPS plan that I was using.  Because of this I started looking around for other options and I settled on www.rackspace.com.  I have been very happy with the process so far and I actually received a phone call from rackspace a couple minutes after I set up my account.

I love the fact that they charge based on time used like AWS but they don't have the odd sizing requirements.

I'm sure in the future I'll post something about how to set up various servers on rackspace.

Goals for 2013

The New Year holiday is an excellent time to take stock of yourself and decide how you want to see yourself progress and develop as a human being over the next year. Normal people like to make resolutions but I think that can be too much of an extreme and you should really be making goals for the next year (it seems to me that resolutions are easy to fall off of while goals can be worked on continually the whole year).

Goals

  1. Learn Zend Framework 2
  2. Learn and use Unit Testing
  3. Using ZF2 and Unit Testing create a free website so I have a playground to try new technologies.
  4. Blog at least 52 times (as a baseline there are currently 29 posts on this site).
  5. Learn how to make a custom Wordpress Theme.

I'll be posting my results on this blog so subscribe to see what's going on.

Google Analytics Tracking Using Zend Framework

Google Analytics is good at what it does. I mean really good. So good that I've been using it for over five years (exactly how long is a mystery to me but I know it's been at least this long) and I haven't ever thought about switching. The thing I like most about it is how brain dead simple it is to setup. It's basically a three step process:

  1. Get Google Analytics Tracking Number
  2. Paste Code Into Site
  3. Browse Reddit for a couple hours

But what if you need to track something a little more complicated? Like a Zend application that has URLs like this:

  • /user/view/id/1
  • /user/view/id/42
  • /user/view/id/1023223f/somethingElse/anotherValue

GA sees that as three different pages instead of being the UserController's viewAction(). Which is annoying because if you don't care about specific items then it's a little misleading about what the "top" pages are on your site.

It turns out that fixing this problem is *depressing *easy. The normal JavaScript code that Google gives you has a section that looks like this:

var _gaq = _gaq || []; 
_gaq.push(['_setAccount','GA-123445-01']); 
_gaq.push(['_trackPageview']); 

This setups the various settings used on the page including the account (_setAccount...). The _trackPageview setting is what actually sets the page your tracking. If you leave this setting blank it uses the current URI. But you can set it to anything you want:

_gaq.push(['_trackPageview', '/user/view']);

I have the Google Analytics code in my layout so I just add the following to my Generic Controller (the controller all my other Controllers extend).

$params = $this->getRequest()->getParams();
$this->view->controller = $params['controller'];
$this->view->action = $params['action'];

Then in my layout.phtml I add:

_gaq.push(['_trackPageview', '/<?php echo $this->controller;?>/<?php echo $this->action;?>']);

Enjoy.

Glyphicons "Free" Monochrome Icons and Symbols

I've been looking at using Twitter Bootstrap as a starting point for my next project and I found they were using icons from glyphicons.com. They are a set of icons that are free that require attribution and two payment options that don't require attribution.

I'm not a big fan of the attribution on the footer but for $25 it's not that bad of a deal if you need a couple of them. Making one icon usually eats at least that in my hourly fees. :-)

Enabling Error Displays In Zend Framework 2

One of the things that I loved most about Zend Framework 1 is that you could run two servers with almost identical configs and easily switch Zend from production to development and have it use completely different configs just by changing one setting. In Zend Framework 2 they've switch away from this method and have added a local.php file option so it works the same way but critical information like account passwords aren't included in Source Control.

One of the things I love most is that you could change PHP settings like enabling display_errors. Internally, Zend Framework 2 doesn't support this but because they've switched to using executed PHP files for settings that are basically executed you can just use the ini_set function to do the same thing as long as the file returns the array:

ini_set('display_startup_errors',true);
ini_set('display_errors',true);
return array();

Link Post: Asshole Driven Development

Asshole Driven development (ADD) – Any team where the biggest jerk makes all the big decisions is asshole driven development. All wisdom, logic or process goes out the window when Mr. Asshole is in the room, doing whatever idiotic, selfish thing he thinks is best. There may rules and processes, but Mr. A breaks them and people follow anyway.

A funny article written by Scott Berkun that I found via Reddit:

http://scottberkun.com/2007/asshole-driven-development/

RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general