k2 Tools Category Filter Bug Fix
A bug in K2 tools stops filtering the categories, and returns a blank menu on the frontend. It works fine with no selection of cathegories in the field “Category filter”, but when selecting a specific cathegory there is no display in the module on the frontend.
The bug is from a forgotten space. A classic typo.
To repair search for the file modules/mod_k2_tools/helper.php and here for the line that reads
$query .= “ORDER BY created DESC”;
the problem is that you need to add a space in front of ORDER, to look like
$query .= ” ORDER BY created DESC”;
because if it enters the if from before it does not add this space. One can add this space in the if also.
Accessing compressed CSS files
When CSS is compress (Firebug refers to the template.php file instead of teh CSS file)
- open index.php
- find the line linking to the CSS file
<link rel = "stylesheet" href="...
- Change the text template.php to template.css (or whatever your css file is called)
- Add a link to menu.css
Text inside forms IE solution
Problem:
Text inside form fields was appearing the the top left corner of the form in IE only.
Solution:
Apply a pixel height to the following CSS properties to the the form:
form {height: Xpx; line-height: Xpx}
3 Column layout Template
More info at this excellent article: http://www.informit.com/articles/article.aspx?p=1152145&seqNum=5
View the source for the template HERE
Fixing the “Screen resolution unknown” problem
I just installed Ubuntu 10.04, and my screen resolution was defaulting to 800 x 600, with no option to increase the resolution. Here is how to fix it.
* It’s worth noting that I had a Matrox G400/450 dual display card in my machine, and while I only use the card with one monitor the information below should work with any standard video cards as far as I know)
- First you need to create a xorg.conf file, as Ubuntu 10.04 doesn’t create one automatically.
Drop to a terminal by pressing Ctrl+Alt+F1 Log in with your usual Username and Password.
sudo stop *dm
where the * you replace with the letter which represents your desktop manager –> g for Gnome, k for KDE or x for xfce
Then put in your password.
once that has finished,
sudo Xorg -configure
This will then create an xorg.conf file in your home directory.
Once this is done,
startx
and you will be bought back to the desktop.
To make the computer use the xorg file next time you boot, create a file in /etc/X11/xorg.conf either by navigating to that folder and Right-click ‘Open as Root’ and then create a new file or
gksudo gedit /etc/X11/xorg.conf
and paste into it what is in the xorg.conf file in your Home directory and click save.
Reboot.
On reboot, my resolution issue was fixed. Hopefully it will do the same for you.
File sharing an external drive with Samba
• Open up the terminal and install samba with the following command:
sudo apt-get install samba
• Now install System Config Samba:
sudo apt-get install system-config-samba
• Restart Ubuntu
• Open up Samba Server Configuration by navigating to the following through the menu bar:
System > Administration > Samba
• In System Samba Server Configuration click ADD SHARE and navigate to your external drive, and select Writable / Visible, and click on Access to give access to everyone.
• In Preferences > Server Settings you can change the workgroup if needed.
• We now need to allow permission for anyone on the network to access your external drive, as even though we have told samba it can be accessed by anyone, Ubuntu will override this and only allow access to the administrator. So, open up teh samba config file using the termonal:
sudo gedit /etc/samba/smb.conf
• Add the following line to the Global section of the config file:
force user = insert your user name here
• Save the file, and restart ubuntu.
and that’s it! You’re external drive should now be accessible from windows machines, macs, and media players.
Fixing the empty desktop in Ubuntu
I had just done a recent re-install of ubuntu, and for some reason my desktop displayed empty. No icons, No menus, just the background image.
To fix this, we need to re-install the desktop by doing the following command:
1. Hold down Ctrl+Alt+F1
2. Login
3. Enter: sudo apt-get install ubuntu-desktop
4. After you are done, return to x-server by Alt+F7 or just restart.
Retrieving data from custom fields for use in your code
This is a great tip if you want to use the data typed into a custom field, and use it in your code.
This example will use it to display a background image for that particular page. Here’s how you would pull the data from a custom field where the key = image and use the value of that field as the “src” value in an IMG tag:
• Open up your theme’s functions.php file and paste the following code somewhere between PHP tags:
function get_custom_field($key, $echo = FALSE) {
global $post;
$custom_field = get_post_meta($post->ID, $key, true);
if ($echo == FALSE) return $custom_field;
echo $custom_field;
}
• insert the following PHP into your theme files:

• Now, let’s take it one step further. Let’s recycle some code from our get_custom_field function and use it in a function that will check to see if that custom field has a value — and if it does, then to use that value, along with the proper IMG tags to output an image, including width and height specifications:
function image_attachment($key, $width, $height) {
global $post;
$custom_field = get_post_meta($post->ID, $key, true);
if($custom_field) { //if the user set a custom field
echo '';
}
else { //else, return
return;
}
}
Then, just use the function in your theme files. This example would echo the image with a width and height of 100px:
* Thankyou to the Nathan Rice blog for this handy hint
Inserting Images in posts using custom fields
• Create a custom filed with the name Thumbnails
• Define the value as a URL (and make sure you upload an image to the server at that URL
• Open up the templates index.php file, and look for the following code: if(have_posts()) : while(have_posts()) : the_post();
and insert this right after it:
// check for thumbnail
$thumb = get_post_meta($post->ID, 'Thumbnail', $single = true);
// check for thumbnail class
$thumb_class = get_post_meta($post->ID, 'Thumbnail Class', $single = true);
// check for thumbnail alt text
$thumb_alt = get_post_meta($post->ID, 'Thumbnail Alt', $single = true);
• In the same file, look for either of the following:
php the_content();
php the_excerpt();
and add the following before it:
• Insert the following into your CSS:
thumbnail-class {
float: left;
width: 100px;
height: 100px;
margin: 0 15px 0 0;
}
.left {
float: left;
margin: 0 15px 0 0;
}

leave a comment