How to check if the user is logged in Drupal 6 using php

I needed this snippet of code in a block to show different links based on the user's logged in state.

  1. <?php
  2. global $user;
  3. if ($user->uid) {
  4.     print "logged in";
  5. }
  6. else if (!$user->uid) {
  7.     print "please log in";
  8. }
  9. ?>
Technology: 

Jquery DataTables number of results per page

You can set the number of results per page in DataTables using
iDisplayLength

so for example:

  1.     $('#example').dataTable({
  2.         "iDisplayLength": 100
  3.     });

Will make DataTables display 100 results per page.

Technology: 

Drupal6 theme single node id

Here's a code snippet for having node-[nid].tpl.php style templates.

  1. function phptemplate_preprocess_node(&$vars, $hook) {
  2.   $node = $vars['node'];
  3.   $vars['template_file'] = 'node-'. $node->nid;
  4. }
Technology: 

Display Drupal 6 Custom menu in theme

There's a small catch, you have to prepend menu- to your custom name in the actual code.
You can check the url of the menu when you're in the admin for getting the actual name, if it's easier for you.

print theme('links', menu_navigation_links('menu-custom-name'));

Technology: 

contype UserAgent requests in Internet Explorer

Requests made by Internet Explorer that set the UserAgent header to "contype" is IE's attempt to figure out the content type of a file that needs to be retrieved.

This usually happens when you embed some type of object into a page, for example a swf or a pdf viewer.

Flash ExternalInterface not working in Internet Explorer

There are a few items you need to make sure are done correctly in order for flash ExternalInterface to work correctly in IE:

1. The object tag needs to have the correct clsid attached
2. If flash is loaded dynamically in the page as opposed to being written in the initial html, the object tag must have an id.
3. In order to access javascript with same permissions as you would have the js code directly in the page, you need to have . make sure allowscriptaccess is written just like that with no capital letters

Open jQuery Colorbox onLoad

I've been searching a bit on how to use Jquery Colorbox onLoad when I finally found out the solution thanks to Biostall.

It seems there's an optional parameter called open that you need to use.

  1. <script type="text/javascript">
  2.         $(document).ready(function() {
  3.                 $.fn.colorbox({href:"thankyou.html", open:true});
  4.         });
  5. </script>
Technology: 

How to remove Safari's input highlight

I bet you thought that only IE has weird problems, but fear not Safari isn't letting him be the only strange kid on the block.

You'll notice that in safari your input buttons have a strange glow around them when they're focused.
That can be removed by using

  1.     input { outline: none; }
Technology: 

How to replace OpenJDK with Sun Java in Ubuntu

Not quite a programming article, but I stumbled in this problem today so I thought it's worth a note.

After you install sun java from the partners repository, you'll see that by using java -version it still shows that it's using OpenJDK.

To fix this you can run:
sudo update-alternatives --config java

That will allow you to choose the default java virtual machine.

Technology: 

How to fix IE7 Z-Index Issues using Jquery

I was searching around for an easy solution regarding the stupid IE7 z-index problems and i stumbled upon this article.

Tweaked the jQuery script a bit by adding the browser check.
Here's the end result for the IE7 z-index problem, it seems to work pretty well for me.

  1. $(document).ready(function() {
  2.     if ($.browser.msie && $.browser.msie < 8) {
  3.         var zIndexNumber = 1000;
  4.        
  5.         $('div').each(function() {
  6.             $(this).css('zIndex', zIndexNumber);
Technology: 

Pages

Subscribe to at-byte.com RSS