This is my first attempt to build a jQuery plugin and maybe there’s already another plugin that does the same thing but it have been a really nice exercise.
This plugin will give you the method
setCounter([maxLength]). If you call it on a textarea field you will get a counter that gets updated every time the user write a character.
maxLength parameter is not mandatory so if it’s undefined you will get a simple character counter like this:
while if you pass an integer to the method the user won’t be able to write a number of character greater than
maxLength and you will get a counter like this:
This is the code. Save it in a text file named something like
jquery.textareaCharacterCounter.js and include it in your page:
I’ve just installed Lotus Notes 8.5 on Ubuntu and the first thing I noticed was the horrible fonts used in the interface. I’ve searched for a setting, but couldn’t find none so Goggle helped me: Notes is looking for a font called Luxi contained in the package ttf-xfree86-nonfree.
Installation is very simple:
sudo apt-get install ttf-xfree86-nonfree
Insert your password and you are done.
I know that mixing scriplets and JSTL in JSP is a bad practice, but sometimes you can’t avoid it and every time I do it I can’t remember how to share variables between scriplets and JSTL so this post is a sort of reminder for the future. Hope it can be useful for other forgetful persons like me :-)
<% String myVariable = "Test"; pageContext.setAttribute("myVariable", myVariable); %> <c:out value="myVariable"/>
<c:set var="myVariable" value="Test"/> <% String myVariable = (String)pageContext.getAttribute("myVariable"); out.print(myVariable); %>
Using the new Firefox awesome bar could result in a frustrating experience, because the SQLite database that holds all the data used by Firefox can get heavily defragmented.
You can get an huge speed improvement running this command inside the Firefox error console:
Components.classes["@mozilla.org/browser/nav-history-service;1"] .getService(Components.interfaces.nsPIPlacesDatabase) .DBConnection.executeSimpleSQL("VACUUM");
Put the command above in the code field (in a single line) and press the evaluate button.
After using the code snippets “as is” I tryed to build a more flexible solution so I’ve come up with this little function:
This function must be called inside the single.php template: it gets the first post’s category, searches for a template named like
single__post_first_category_slug_.php and returns its path; if the file doesn’t exists it will return the single_default.php template path.
Today, while trying to customize the single.php template for a specific category I found a pretty old article written by Lorelle:
Her tip is really simple and really useful: just rename your
single1.php and create a new
single2.php with your category specific layout; after that, create a new
single.php file with this code:
So, if the post is in category 1 WordPress will use the
single2.php otherwise it will use
I wrote a more flexible solution: check it out.
WordPress has a simple function to build a search form for your blog and in this tutorial I’ll show you how to add a category filter to it.
This function will look for a file called
searchform.php inside your template folder: if it doesn’t exist it will output the standard search form. So, if it isn’t already in place, create your custom
searchform.php and copy into it the default search form output. It should look similar to this:
We want to add a select box to let the user search in a specific category or in all tags: to achive this we’ll use another default WordPress function.
Now add the category select box to the form modifying your searchform.php like this:
That’s it. It just works out of the box.
Now that you have a nice category filter in your search form it would be great to modify the search result page and add something like Search result for “foo” in category “bar”. Well, it’s quite easy: we need do add a simple function to the function.php file. Remember that every function in this file will be automatically available in your theme.
This is a simple function that gets the cat parameter from the request and if it’s not null it searches the category name. It has two input parameters so you can pass two strings to be displayed before and after the category name. If cat is null or empty or “0” (All tags) it will return an empty string.
Now open you search.php, add the function call to the page and you are done: