Drupal 7 – Use Checkboxes for Exposed Taxonomy Term filter in views

Drupa 7 Views renders exposed taxonomy term filters as either a select box / drop-down or an auto-complete. This may not be the best option especially if you allow the user to select multiple terms to filter with. So is there any way to render these filters as check-boxes instead? Well the bad news that you can’t by default, but the good news is that there is a module called Better Exposed Filters which allows you to do it easily!

 

To switch the filter to checkboxes, first install the module. Then make sure that your filters are exposed in block form – to do this open the ‘Advanced’ section in views and under ‘EXPOSED FORM’ set ‘Exposed form in block:’ to yes. Now change the ‘Exposed form style:’ setting to ‘Better Exposed Filters’ and then edit its settings by clicking on the ‘BEF Settings’ link.

 

drupal views exposed filter checkbox

 
 

In this screen find you taxonomy filter and in a select box like this ‘Display “tid” exposed filter as’ change the value to ‘Checkboxes/Radio Buttons’.

 

Now once you save your view the term filters should be rendered as check boxes!

 

drupal views taxonomy term exposed filter checkbox

 

Build / Cross Compile lighttpd for ARM Linux with pcre

This is a record of how I built lighttpd with pcre for ARM. Most examples of cross compiling lighttpd for ARM do not include pcre, but to get the best out of lighttpd you really do need pcre built in. So we first need to get and cross compile pcre and then lighttpd.

Build pcre for ARM

In this example I assume that you create the build directories in you home directory, e.g. /home/youruser/ , you will need to change this in the following commands to match your actual directory set-up.

cd /home/youruser
mkdir buid_pcre
cd build_pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
tar -xzf pcre-8.21.tar.gz
cd pcre-8.21
./configure --host=arm-linux-gnueabi CC=arm-linux-gnueabi-gcc \
AR=arm-linux-gnueabi-ar STRIP=arm-linux-gnueabi-strip \
RANLIB=arm-linux-gnueabi-ranlib \
--prefix=/home/youruser/build_lighttpd/build_pcre/_install
make
make install

This should build pcre and install the output files into the following directory:

/home/youruser/build_lighttpd/build_pcre/_install

Change this path to suit your own needs.

Build lighttpd for ARM

Now that we have build pcre we can build lighttpd as follows, there is a bit of trickery involved for getting it to build with pcre, but happily this article showed me the way (thanks)!

cd /home/youruser
mkdir build_lighttpd
cd build_lighttpd
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.32.tar.gz
tar -zxvf lighttpd-1.4.32.tar.gz
cd lighttpd-1.4.32
./configure -prefix=/home/youruser/build_lighttpd/_install \ 
-host=arm-linux-gnueabi CC=arm-linux-gnueabi-gcc \
RANLIB=arm-linux-gnueabi-ranlib STRIP=arm-linux-gnueabi-strip\
--enable-shared --without-mysql --without-zlib --without-bzip2 \
--disable-ipv6 \
PCRECONFIG=/home/youruser/build_lighttpd/build_pcre/_install/bin/pcre-config \
PCRE_LIB=/home/youruser/build_lighttpd/build_pcre/_install/lib/libpcre.a \
CFLAGS="$CFLAGS -DHAVE_PCRE_H=1 -DHAVE_LIBPCRE=1 -I/home/youruser/build_lighttpd/build_pcre/_install/include"
make
make install

Again remember to change: /home/youruser/ in each case.

If the build succeded, all the files that you need to install lighttpd on your target ARM device should be under: /home/youruser/build_lighttpd/_install

Here is an article which talks about how to manually install lighttpd.

But at a very minimum you need to:

(a) Download and edit the config file – lighttpd.conf
(b) Copy the pcre libs to /usr/lib or similar – libpcre.so.0 , libpcre.so.0.0.1
(c) Copy on the lighttpd binary from: /home/youruser/build_lighttpd/_install/sbin
(d) Copy on the lib folder from /home/youruser/build_lighttpd/_install/lib
(e) Run lighttpd specifying the paths to config file and lib folder, for example:

lighttpd -D -f /etc/lighttpd/lighttpd.conf -m /usr/lib

Thanks to the following articles for the build info!

http://fengh2000.blogspot.ie/2009/06/how-to-cross-compile-lighttpd-with-pcre.html

http://stackoverflow.com/questions/12079498/lighttpd-refernces-wrong-lib-location

Boost link error – undefined reference to boost filesystem detail copy_file( )

I had some difficulty today getting my code to link to boost::filesystem::copy_file() (linking to boost version 1.53.0, gcc v4.7.2), I suffered from link errors like this:

undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option, boost::system::error_code*)’

From reading this post, it seemed that my problem may have stemmed from my use of c++0x.

 

None of the suggested solutions in this thread worked for me & I double checked that had built boost with -std=c++0x.

 

In the end after looking through the code in filesystem/operations.hpp the only thing that fixed my linking problem was to #define BOOST_NO_CXX11_SCOPED_ENUMS before including , like this:

#define BOOST_NO_CXX11_SCOPED_ENUMS
#include 

This may well not be the best/proper way to fix the problem but it was the only thing that worked for me..

 

Other relevant links that I found are here, here and here.

 

boost filesystem compile warnings – boost system posix_category defined but not used

If you are using boost::filesystem in your C++ code and getting are some build warnings along the lines of:

 

‘boost::system::posix_category’ defined but not used

 

Then you may find that inserting the following code before #including boost/filesystem gets rid of them for you:

#ifndef BOOST_SYSTEM_NO_DEPRECATED
#define BOOST_SYSTEM_NO_DEPRECATED 1
#endif
#include 

This gets rid of some the deprecated stuff that was causing the warnings.

 

I found this handy tip here:

 

http://stackoverflow.com/questions/1814548/boostsystem-category-defined-but-not-used

 

Fedora released for Raspberry Pi

Another OS option for your Pi – Fedora Remix has been released for the Raspberry Pi, it is based on the Fedora ARM secondary architecture project, more details can be found here:

http://zenit.senecac.on.ca/wiki/index.php/Raspberry_Pi_Fedora_Remix_FAQ

I love the 4th. item in the FAQ, it is entitled – “Why is the Remix slow?” lol

It makes me very curious, just how slow is it? I guess I will have to install it to find out! :-)

Building / Cross Compiling OpenCV for Linux ARM

This article outlines the steps necessary for building OpenCV for a Linux ARM target. OpenCV is an open-source, cross-platform computer vision and machine vision library.

 

I cross compiled OpenCV for a Xilinx Zinq ARM system yesterday by more-or-less following the steps outlined in the above document – I had to change a few things to get the build to work. I am documenting the exact steps that I took in case anybody is having trouble (probably future me!).

 

I started with a fairly clean Ubuntu install on a virtual machine (it already had git installed) , first I installed some build tools, feel free to skip any that you already have:

sudo apt-get install build-essential
sudo apt-get install cmake

Then I installed the GNU ARM tool-chain:

sudo apt-get install gcc-arm-linux-gnueabi
sudo apt-get install g++-arm-linux-gnueabi

This installed version 4.7 of the compilers while the build process calls for version 4.6, to get around this I modified the cmake platform file slightly, see below.

 

Create a build directory, cd into it and get the OpenCV source from github:

mkdir opencv_build
cd opencv_build
git clone https://github.com/Itseez/opencv.git
 

To fix the version problem I modified the compiler version in the platform file (this may not be the most correct way to do this but it worked for me!):

 

I edited this file:

 

./opencv/platforms/linux/arm-gnueabi.toolchain.cmake

 

I changed the GCC_COMPILER_VERSION variable’s value from 4.6 to 4.7 to match my installed compiler. I had to edit the file as I wasn’t able to override these variables from the command line.

 

Now create a sub-directory called build and cd into it:

mkdir build
cd build

And configure the build:

cmake -DSOFTFP=ON  -DCMAKE_TOOLCHAIN_FILE=../opencv/platforms/linux/arm-gnueabi.toolchain.cmake ../opencv

This should complete without errors if you have the compiler that it is looking for installed etc.

 

Now run ‘make’ and ‘make install’:

make
make install

Make will take a few minutes to run, make install should copy the output files to a subdirectory called ‘install’.

 

All being well you should now have all the include and lib files that you need to build an OpenCV app for your ARM device.

 

Cross compiling libjpeg for Linux on ARM

I am taking this opportunity to document a cross compilation procedure for libjpeg targeting ARM Linux mostly so that I won’t have to go searching for it again in the future!

First create a directory and cd to it: 

mkdir libjpeg_build
cd libjpeg_build

Now get the source and un-tar it:

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
tar -xzvf jpegsrc.v9.tar.gz

Configure the build, specifying your C compiler and cross compilation host, then make:

./configure --host=arm-xilinx-linux CC=arm-xilinx-linux-gnueabi-gcc
make

Here, I am using the xilinx build of the compiler, hence the reference to xilinx in the host and CC parameters, if I wasn’t using the xilinx tools the above configure command may have looked more like this:

./configure --host=arm-linux CC=arm-linux-gnueabi-gcc

Now make install, specifying a directory for the output:

make install DESTDIR=./_install

If all goes well the output of the build process should be written to the _install directory, copy the .so files to the appropriate directory on your target device (e.g. /usr/local/lib)

Enterprise Architect UML – Add C++ #include code statements for dependency relationship

By default #include statements are not inserted into files for dependency relationships when generating C++ code from UML models in Sparx Enterprise Architect – this is a bit annoying but we are well used to UML editors doing annoying things so at least it’s not a terrible surprise!

 

In Enterprise Architect’s defence it is quite easy to add this missing functionality. In order to get it to generate #include statements we have to edit two of the code generation templates: “Import” and “Import Section”.

 

To edit the templates go to the “Settings / Code Generation Templates…”, menu and you should see a list of the templates on the left-hand side of the screen.

 

Change the “Import” template so that it looks like this:

$file = %importFileName%
%if $file == "" or importInFile=="T" or $file == fileName%
%endTemplate%
#include "$file"

And then change the “Import Section” template so that it looks like this:

$COMMENT="WARNING: THIS IS AN ADVANCED TEMPLATE"
$COMMENT="DO NOT MODIFY UNLESS YOU ARE AN"
$COMMENT="ADVANCED USER!"
$imports += %list="Import" @separator="\n" importFromDependency=="T"%
%REMOVE_DUPLICATES($imports, "\n")%

%fileImports%

Now when you generate C++ code from your modle #include statements should be inserted to satisify dependency relationships.

 

Thanks to this article for the instructions (in German!).

 

Drupal 6 – Easy Social buttons not displaying in node

If you are using the easy social module in drupal 6 with a quirky (read rubbish) theme (or sometimes ubercart) then you may notice that the social media buttons don’t get displayed on some node types.

 

To get around this problem you may have to alter the node’s template to manually insert the Easy Social module’s output – and hence the social media buttons. Add the following to the relevant node template which can be found in your theme folder:

easy_social ;?>

More information can be found here.

 

PS It’s high time you were using drupal 7! ;-)

 

GCC, std::thread – type ‘sleep_for’ is not a member of ‘std::this_thread’

If you are trying to use sleep_for() in the standard C++ thread library via GCC and are getting an error like the following:

 

‘sleep_for’ is not a member of ‘std::this_thread’

 

The you may have to define the following symbol:

 
 _GLIBCXX_USE_NANOSLEEP

More information can be found here.