Today: May 12th, 2008

Tag or Function for WP Plugin

As far as I know, there are two ways to output the result of your plugin queries in Wordpress. One is to use the function call to echo/print the result and the other is to use add_filter function of WP which uses tags to append the result to the content. If coded correctly, there are no noticeable difference in the final result. However, in terms of performance (regarding speed and number of queries) there may seem a bit of overhead in using the add_filter function (and subsequently a tag).

When I first wrote (copied is a more accurate term) KG Archives Plugin for WP, I went for the add_filter approach to output the result of my queries. One reason for going that path is that the plugin written this way can be easily installed by novice and those without PHP background users. Good examples of this type of plugin are WP ContactForm and KG Archives plugin I have here. As of WP ContactForm’s case, it can be easily added to any page by just clicking the “Quicktags” above the post textarea. There are not much coding involve just uploading the files and activating the plugin.

The add_filter as I found out (while fixing the huge queries problem KG Archives is generating) has one drawback: the plugin is queried everytime blog contents are displayed. It gets queried on pages where it is not displayed. For example, KG Archives generates archives on my archives page but if you read the posts, the KG Archives plugin is still queried, it is just not being displayed in the resulting output.

My solution is that I have added a test on whether the page being called is the page where the plugin should do its work, if not, then exit the function. This way the rest of the code will not execute.

On the other hand, direct function calls to the plugin can be used and the problem will go away. It does not append the result to WP’s content variable but is echoed out directly. This also has a drawback, however. There is a need to open or , sometimes, create a template file and call the function directly. This approach is making newcomers feel uncomfortable as they find it hackish.

Like the first time I came to Wordpress world, I just download a theme and start blogging. The template system was hard to comprehend. And there are people whose concern is to blog only. These are the type of people who are used to the notion of they’ll only use softwares and tools that “just works”. They can’t even secure their desktop PC’s let alone hack the template of their chosen blogging tool.

KG Archives V1.3

Thanks to Ajay and Carsten for pointing out the huge amount of queries that KG Archives V1.2 is generating. This is due to nested queries and permalinks fetching for the posts. I have now fixed the issue and is now only generating 4 queries and the permalinks are no longer fetched using WP’s get_permalink function. Instead, I have embed the function’s code into mine taking out the db calls to get the posts.

Anyway, version 1.3 can be downloaded at http://katesgasis.com/downloads/kgarchives-1_3.zip.

This time the archives page must have a slug of “archives” so that the plugin will not generate queries if not in the archives page.

Installation

  • 1. Uploade the kgarchives.php file to your plugins directory (/wp-content/plugins).
  • 2. Activate the plugin in the admin panel.
  • 3. Create a new page. Name it anything but make sure the slug is labeled as “archives”.
  • 4. On the page content, put the tags <!−−KGSortForm−−> and <!−−KGSortArch−−>.

Terrible Cook

Yesterday, I embarked on a journey. I’m going to cook for lunch today. I decided to cook chicken macaroni soup. Easy eh? Last night, I have all the ingredients bought. Or so I thought. This morning, I found out that I’m going to cook without a recipe. Luckily, I have the handy dandy internet. I googled for a recipe and found one. Looks easy when I read it. After comparing what I have and what is needed, I hurriedly drive to a nearby grocery store. Then I began cooking.

The problem was that the stupid recipe writer did not list one of the ingredient that will be used. The ingredient was first listed in the procedure part of the recipe. Stupid me for not reading. At this moment I realized that C (the programming language) was friendly after all. No wonder I can’t stop coding in C. At least requires (not so strict though) you to declare all variables you will be using later at the top of the function block. This recipe doesn’t.

The result? We ate outside food. My wife has been wanting to kill me (she look like she will). She is currently ill with “mumps” and is having a hard time swallowing. I really have to remind myself to not cook next time around.

Photo Gallery

There will be times that the gallery section of this site is down. Visitors will see a message of unavailability together with some explanation why it is so.
The gallery section is powered by Flickr made possible through a plugin called Flickr Gallery. The failure is not caused by the plugin but by Flickr. Flickr is being further develop and there are times that the plugin cannot access the API or even the photos themselves.

There are other photogallery solutions available for Wordpress like Coppermine which resides on your own server but my choice of using Flickr is based on the disk space requirement available to my hosting account. With the number of pictures that I have already uploaded, there will be no room left for me to blog.

By the way, I have not tried using Coppermine first hand. I don’t know if there are other better deals or solutions available out there.

MT and TXP

I was learning a lot about design lately. Reading great designers and design resource site gives me a lot to think about my skills in design. Mark Boulton has just published the last part of his Five simple steps to better typography and has taught me how to go about using fonts properly.

Jumping from one designer’s site to another, I observed that most of the sites/blogs I read is either have MovableType or Textpattern backend. Does this imply that People who design better are using the aforementioned blog software? I am not claiming that Wordpress sites/people are inferior in design talent. This is only my observation that most sites that teaches or write about design are written on MT or TXP.

AJAX Approach

I was curious on how did Flickr managed to change the way /i view my images that has notes. I know that they used Flash to deliver the images before. Lately, I accidentally right clicked on that panel and there was no “About Macromedia 7…” pop-ups that appear. This I found later on some blogs I have read that Flickr has replaced Flash with AJAX. So what the hell is AJAX? From what I have read from AdaptivePath who came up with the name, it is a new approach on delivering contents to the clients. AJAX, they claim lessen the stop-go-stop-go behavior when we navigate, browse and use web application. Yes, it is a way to design web application. They also said that, AJAX is not a new technology but is compose of existing technologies: Javascript and XML. AJAX, by the way, stands for Asynchronous Javascript + XML. What it does is it fetches data from the server asynchronously without us doing anything making the application faster to load the moment we click (or not click) the appropriate button. At least that was what I understant about it. It is a very promising approach. Complete details can be found here. Being inclined at programming, this indeed is promising. Gmail and Google Suggest is already using it.

Upgraded to WP 1.5.1

I have just upgraded to Wordpress 1.5.1. The upgrade was quick even with a dialup access. It breaks a plugin or two but the authors of the plugin I was using are quick to release a WP 1.5.1 compatible version. Others released it even before the official announcement for the release of 1.5.1 was made.

Happy Birthday Lola Loring

Happy birthday Lola Loring.

IE Woes

IE wasted my time looking for workarounds for their rendering bug. Floats and Boxes that just don’t work the way I intend them to. All the while I thought I’m done with the layout and colors in Firefox realizing only that it’s a mistake to design using it. By the time I tried to view in IE, the ever uncoordinated design became chaotic. A box here, an out of line border there.

I thought I have a pretty good grasp with CSS. I was proven wrong. Visiting CSSZENGARDEN opens a world of sites full of priceless information on how “limitless” you can do with css. Clicking endlessly though the links lead me to Edwardson Tan’s hack on boxmodel. I found it easier to implement and remember than Tantrek’s. In my previous layout, I was using Tantrek’s hack but can’t seem to make it work. I went back to not using paddings relying only on margins to space the elements.

And so this site. It still resemble the last layout. I must admit, it look a whole lot better than the last. The header was intended to remain blank for now (I’m poor at graphic design as well). But I’ve been working on it on my mind.

When I’m done with redesigning this site, I will be releasing another plugin. This plugin will allow you to rearrange the order of your post depending on how you want them to appear. Stickies can only do so much. Posts in the middle, as opposed to those on top or bottom, can be rearranged. Stickies can only manipulate the most recent post come after the post that you have marked as sticky. My plugin will totally rearrange the order in the database. I know it is somewhat risky. But this is where I’m better at. Programming. Anyway, I only finish about 30% of the code. I don’t know if this plugin is needed. For me, I have some need for such functionality.

A New Design in the Making

Damn, just when you thought you have your best design and then you stumble upon another site that just too appealing and BAM!!! You gotta have that too. There’s just too many of those easy on the eyes sites floating around that just by looking at them and tabbing back to my site make me squirm. They are just too good at designing sites, period. I wonder until how many number of redesign will this site get before this’ll be close to others out there. I can’t even get the typeface look consistent. Now the colors are beginning to monotone again.

But no. Me don’t stop till me am satisfied with my work or else others won’t too. Oh well, this is my sort of a training. If it doesn’t work the first time, then make it even until the nth time. One day, I’ll get better at this.

Next Page »