Currently Browsing: Featured Articles

Search feature on static HTML sites – The smart way

You all must have stumbled on static HTML sites. Either you created them or you found them around. The purpose of those sites today is simplicity. Not everybody needs dynamic content and thus not everybody needs complex CMS’s with huge back end administration panel. So, what is more easy than putting together a few simple HTML pages. But what if you want to incorporate a search feature into that? Well, when a developer first thinks of search, the second thing that hits his mind is “database“. If you fall for that, then there goes simplicity and fast loading. You are already on a war path.

I’ve been challenged to that and here is what i came up with. I created a small PHP script that actually searches the HTML files! The simplicity in the thought is what makes me happy about this. You just get a search term, open the HTML files up, pattern match for it and then echo the results with links back to the original static files. So, you have a dynamic search feature with static content! And what’s even better is that if you make any changes in the HTML files, those will be reflected on your search just like it would happen using the classic database way.

I have created the script and included it with a small example here: Dynamic search for static HTML (482) The only requirements to run this example is a web server with PHP installed. Here is how to check it out:

  • Download and extract the folder “search_test” into a place accessible from the web.
  • Hit the URL “http://place.of.folder/search_test/search.php?s=ipsum

As you can see, the above URL will search for “ipsum” in the .htm and .html files and show you the results. If you want to play a little bit with the parameters of the script you can open it and check the global variables on the top (recursive search, highlight etc).

One thing that could be improved is cached search. This would decrease the load on the server for each search. I can help you do it if you need to. I just didn’t go on with it because i didn’t want to over-complex my script.

As you can imagine, this is just the skeleton of the script. You should configure it to fit your needs. If you have any problems or need any help don’t hesitate to leave a comment or contact me!

EDIT: I forgot to mention that this will work for text that is wrapped around a “<p>” (paragraph) tag. In order to make it work with more or be more flexible, you will need to edit the regular expression at the “preg_match_all” call on the script.

Get rid of the newsflash plugins. Do it yourself!

Does the title ring a bell? I bet it does. It must remind you of the article i wrote quite some time ago titled “Get rid of the sociable plugins. Do it yourself!“. It helped a lot of people save some CPU time and memory usage. Now it’s time for the newsflash! The idea came to me after i read this article on a modification for the theme. It actually gives a very nice little admin area on the theme options but it fiddles with the database so i decided to show you how you can do the same thing without any query run.

Firstly, i will summarize all the steps we are going to take in order to achieve this:

  1. We will have a plain text file called “newsflash.txt” in our theme folder. This file will actually contain the newsflash we want to display to the visitor. If it’s empty, or not there at all then nothing will be shown.
  2. On the “index.php” file of our theme we will be adding a few extra lines of code that will actually do just that. Check for the existence of the file and if it’s there and has things in it, then a newsflash div will be rendered before the posts do.
  3. Skin the newsflash div box through the style.css file.

The result will look something like the following.

newsflash

(more…)

Lines from “Whose Line”

whoselineisitanywayI’ve always liked American shows, series (like “Three’s company”) and stuff, i guess culturally it fits me. I also love stand up comedy. Actually anything that has to do with it, stand up, imrpov etc. About a year ago i discovered a great show, “Whose line is it anyway”. It started as an English show, back in the eighties and then in ’98 it went to the states. I guess all my American readers should already know what i am talking about, all the othersshould have to take a quick look on Imdb.

(more…)

Insert the post title in your “read more” tag easily

Watching twitter today, i came across a tweet from Kikolani. Now i’ve been following her for quite some time getting valuable feedback and post ideas. Today’s tweet was about a post on TechJaws called “The Biggest Mistakes in SEO” which i found interesting. As always i have my agrees and disagrees but still it was a nice read. One of the author’s points was ““Click Here” or “Read More” Link Anchor Text“. Here is what he suggests:

Many people use “Clíck here” or “Learn more” as the linking text. This is great if you want to be ranked high for “Click Here”. [...] It’s much more descriptive (and relevant) to say “learn more about {keyword topic}”

I see the point on this and i agree. Besides, the info has already been retrieved from the database so no more extra load is going down. It’s not only SEO friendly, it’s reader friendly as well. That’s what’s most important. On the comments, Kikolani said she hadn’t figured out how to do it. I thought that many non techy people out there might find it hard, as well. So, here is how i did it! (notice it on the read more following)

(more…)

101 Sociable links for manual insertion in WordPress

A few months back i had a post about how to get rid of your sociable plugins and doing the same thing by editing your theme. In that post i have included a few popular sociable networks such as Digg and Stumbleuppon but today i have decided to include as much as possible, 101 to be exact. You can go through them and decide which ones you want to use. The links are included as they should be in your theme. Take a look at the older post on how to do it and get the links from here.

I used the Sociable plugin source code to extract the links. You can also find images for the links herein here (also from the same plugin): 101 Sociable images (420) - 82.18 KB

As an example of how to use it, here is one with Digg:

  1. <a href="http://digg.com/submit?phase=2&amp;url=<?= the_permalink();?>&amp;title=<?= the_title();?>">Digg</a>

For more details please check out the older post. So here we go!

(more…)

« Previous Entries