Just had my first taste of India….
Posted by Avi in Programming on June 3rd, 2010
I got to turn this:
<?php $i=1?> <?php query_posts('category_name=Projects2&showposts=3&orderby=rand'); ?> <?php while (have_posts()) : the_post(); ?> <?php if($i==1) {?> <div class="set set1"> <div class="title"><h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4></div> <div class="content"> <a href="#"> <?php $values = get_post_custom_values("image"); ?> <img src="<?php echo $values[0]; ?>" width="242" height="148" alt=""> </a> <!--content end--></div> <!--set set1 end--></div> <?php } elseif($i==2) {?> <div class="set set1"> <div class="title"><h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4></div> <div class="content"> <a href="#"> <?php $values = get_post_custom_values("image"); ?> <img src="<?php echo $values[0]; ?>" width="242" height="148" alt=""> </a> <!--content end--></div> <!--set set1 end--></div> <?php } elseif($i==3) {?> <div class="set set1"> <div class="title"><h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4></div> <div class="content"> <a href="#"> <?php $values = get_post_custom_values("image"); ?> <img src="<?php echo $values[0]; ?>" width="242" height="148" alt=""> </a> <!--content end--></div> <!--set set1 end--></div> <?php } else {?> <div class="set set1"> <div class="title"><h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4></div> <div class="content"> <a href="#"> <?php $values = get_post_custom_values("image"); ?> <img src="<?php echo $values[0]; ?>" width="242" height="148" alt=""> </a> <!--content end--></div> <!--set set1 end--></div> <?php } ?> <?php $i++; ?> <?php endwhile; ?> <?php wp_reset_query();?>
Into this:
<?php query_posts('category_name=Projects2&showposts=3&orderby=rand'); ?> <?php while (have_posts()) : the_post(); ?> <div class="set set1"> <div class="title"><h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4></div> <div class="content"> <a href="#"> <?php $values = get_post_custom_values("image"); ?> <img src="<?php echo $values[0]; ?>" width="242" height="148" alt=""> </a> </div><!--content end--> </div><!--set set1 end--> <?php endwhile; ?> <?php wp_reset_query();?>
Needless to say, my client will no longer be outsourcing to India.
Review of the Apostrophe CMS for symfony
Posted by Avi in Programming on April 21st, 2010
I know I gave my blessing before to diem, and I’ll still admit that it is a very good CMS. However, it has always bothered me a little bit just how invasive this CMS is. While it bills itself as a symfony plugin, it is in truth anything but. You must start out using diem, and then add a little symfony in when you need it.
I was reading, recently, a post on the sympal blog. In this post, Ryan Weaver echoed my latent feelings that a CMS should empower your site with CMS capabilities, but should not take it over completely. In other words, the perfect medium would be in the form of a plugin for symfony 1.x, or bundle perhaps for Symfony 2.x.
There was a comment put in there by somebody from the apostrophe team, which made me realize that, apostrophe was perhaps already meeting this goal. Seeing as I needed to pick a new CMS for an upcoming project, I thought I’d take it for a spin. Read the rest of this entry »
The end of the PHP vs Template language debate?
Posted by Avi in Programming on February 10th, 2010
For years there has been a ferocious debate about whether it is better to abstract away HTML creation with PHP by using a template language, or whether we should stick with PHP itself as the template language. I always thought the best way to go was a with a hybrid. A templating language which resembles XML, sort of like what you get with JSTL. There have been some attempts , which have been pretty good. Facebook, however, just took this one step further, and integrated XML into PHP with XHP. This is sort of reminicient of XML Literals in VB. They have released the code on github already. The best part about it is that every XML element is represented by a class, leaving room to create sophisticated widgets out of XML tags!
Diem, my new CMS of choice
Posted by Avi in Programming on January 4th, 2010
Every since I started getting frustrated with Expression Engine, I was always looking out for something different. A CMS aimed at developers. Just about every CMS on the market is aimed at letting less technical people get out their and create content. There are a few CMSs that bill themselves as a Content Management Framework. In other words, they provide with the tools to create your own custom CMS. In fact, I would actually put Expression Engine in that category. Others that come to mind are Drupal and EzPublish. Both of these, for some reason, I was never able to wrap my head around. Then again, I never spent much time with them either. Drupal is written procedurally (at least they admit it) which is not my style. Something always goes wrong when I try to install EzPublish.
Then of course there is the option of RDBMSWAAS. When thinking about that last option, there are two frameworks that come to mind, Symfony, and Django. I tried Django before for a small project, and it worked out well, but I had never really given Symfony the time of day. When looking at the Symfony website, I stumbled across a nice hidden gem. Read the rest of this entry »
Quick code review of Expression Engine 2.0
Posted by Avi in Programming on December 29th, 2009
I just got a hold of the public beta of Expression Engine 2.0. I have been using Expression Engine 1.x for a number of years now, and I’ll admit, I wasn’t the most experienced PHP programmer at the time. It was probably the first large PHP program that I had ever used, and I was a little bit awed at how such a massively big OO program could be written.
Since then, I’ve improved my skills tremendously. I’ve learned about SOLID, and DRY. Dependency Injection and Test driven design. I’ve learned about domain modeling, and proper OO design. The code in EE 1.x is utter crap, of course! Global variables scattered everywhere. Copy & Paste style coding. Non-resuable components. No coherent API to speak of. Purely designed plugin system. Who could blame them, though. The code was written almost 10 years ago, in PHP4–with no intention of dropping PHP4 support.
I think I first heard about EE 2.0 almost two years ago. It was coming out that summer. Ever little bit of news that came out made me a little more gittier. It was going to be built on Code Igniter, an MVC framework. Boy was I suprised. Read the rest of this entry »
CQRS (Command and Query Responsibility Segregation) in PHP
Posted by Avi in Programming on December 10th, 2009
It always seems to me that the PHP world is one step behind the current trends in the “enterprise world”. For example, Rails popularized the “ActiveRecord” pattern a few years ago. Ever since then, there has been an explosion of ActiveRecord implementations in PHP. Many even mistakenly refer to them as an “ORM”, but I won’t beat a dead horse here. ActiveRecord is great for your basic run-of-the-mill address book/cookbook/blog type of app, where it basically data driven, and there’s not much “business logic” to go around. For the majority of PHP applications out there, these tools are a god send.
As PHP matures, especially the object model, advanced developers have started to realize the limits of this pattern. Now the big rage is the DataMapper pattern, and DDD. We try to separate out the domain of application, and the holy grail is now transparent persistence. With great tools like Doctrine 2.0 and Object_Freezer, both of which are only possible with the new additions in PHP 5.3, these dreams are becoming a reality.
Read the rest of this entry »
Alternative to Zend_Form ViewScript decorator
Posted by Avi in Programming on November 29th, 2009
Zend_Form is great for prototyping forms. It takes a lot of the drudge work out, and makes forms easily “reusable”. The decorator system, which is admittedly a little scary for the uninitiated, is actually very powerful. I’m suer that eventually, however, we’ve all reached that point. The point where you spend more time configuring the form to do what you want, then actually doing something with it. Read the rest of this entry »
Making Zend_Auth more “Object Oriented”
Posted by Avi in Programming on October 29th, 2009
Recently Giorgio Sironi wrote a post on Zend_Auth. When I saw the title, I was expecting something along the lines of most of his posts, which have been discussing many OO topics. The content was rather disappointing, and I’ll tell you why.
Read the rest of this entry »
Fixing PATH_INFO on bluehost and other shared hosts
Posted by Avi in Programming on August 7th, 2009
The first time I setup an Expression Engine site on bluehost, and removed the index.php file via the .htaccess file, I ran into a problem where every template was redirecting back to the main index template. At the time, I traced this down to fact that the “segments” were not getting populated properly.
A brief search led to the EE wiki, which advocated swapping out PATH_INFO for ORIG_PATH_INFO. Although not being a fan of hacking core stuff, I was kind of cornered into this, so I went for it. This has been my running solution for the past two years.
Recently, I ran into an issue where the $_SERVER['PHP_SELF'] was not returning anything after the file name. In other words, for http://mysite/foo.php/bar, PHP_SELF should be equal to foo.php/bar.
I spoke with my host about it (a similar host to bluehost), and they said to put the following in the php.ini file: cgi.fix_pathinfo=Off
After, I did this, PHP_SELF worked fine. Unfortunately, I ran into a similar situation like I described at the outset. Then it hit me…I changed ORIG_PATH_INFO back to PATH_INFO and…it worked!
So now I listed this as another potential solution in the EE wiki.
The joys of the command line
Posted by Avi in Programming on July 13th, 2009
I’ve always loved the unix command line and its power. I recently found the website http://www.commandlinefu.com which people can submit their own command line goodies. This really shows off the power of the command line!