Category: Open Sourced

Search function for the User Groups module for ExpressionEngine

I wrote a quick search function for the User Groups module for ExpressionEngine. It searches groups (names and descriptions) as well as topics and topic replies. It respects group types as well - results from private groups will not show up in the topic or topic replies search results. You can download it here or see it here.

It’s very simple and can probably be optimized, but it works.

Let me know if you have any questions or comments. I’ll probably end up updating it as new versions of the User Groups module come out.

The search form I use with it is below:

<form id="group_search" method="post" action="{homepage}/groups/search/">
<
input type="text" id="group_search_box" name="group_search_box" />
<
input type="hidden" id="member_id" name="member_id" value="{member_id}" />

<
input type="radio" name="search" value="search_discussions" id="search_discussions" checked>Discussions
<input type="radio" name="search" value="search_groups" id="search_groups"Groups<br>
<
input type="submit" value="Submit"/>
</
form

Posted on Nov 19, 2009 - 07:15 PM

How to create categories from the frontend in ExpressionEngine

I figured out a nifty way to let users on the frontend create categories in the backend. (This isn’t currently possible with the SAEF.) It’s a little bit of a hack, but it works - if you have improvements upon it, please let me know.

You’ll need two templates: one with the form that the user submits with the category name and description (I’ll call this the index template), and one with PHP enabled (parsed on input, NOT output), which I’ll call the create template. In this instance, I’m creating a groups equivalent for users based on categories.     

Here’s the entire contents of my index template:

<form action="{homepage}/groups/create/" method="post" name="group_create">
<
p>Group Name
<input type="text" name="group_name">
<
br />
Group Description
<
input type="text" name="group_description">
</
p>
<
input type="submit" value="Submit" />
</
form

And here’s what I have in the create template:

<?php

global $DB$REGX;

$_POST $REGX->xss_clean$_POST );

$cat_query $DB->query("SELECT AUTO_INCREMENT FROM information_schema.tables WHERE 
table_name='exp_categories' AND TABLE_SCHEMA='your_db_name' ORDER BY Auto_increment DESC LIMIT 1"
);
foreach(
$cat_query->result as $row){}

$cat_id 
$row['AUTO_INCREMENT'];
$site_id "1";
$group_id "4";
$parent_id "0";
$cat_name=$_POST['group_name'];
$cat_title $REGX->create_url_title($cat_name);
$cat_description =$_POST['group_description'];
$cat_image "";
$cat_order "0";

//Creates the SQL query: see http://expressionengine.com/docs/development/usage/database.html
$data = array('cat_id' => $cat_id'site_id' => $site_id'group_id' => $group_id,
 
'parent_id' => $parent_id'cat_name' => $cat_name'cat_url_title' => $cat_title,
 
'cat_description' => $cat_description'cat_image' => $cat_image'cat_order' =>
 
$cat_order);
 
$sql $DB->insert_string('exp_categories'$data);

//echoes the SQL query instead of inserting it - uncomment $DB->query($sql); to make it live.
echo $sql;
//$DB->query($sql);
?> 

A couple of notes: I hard-coded the group_id, site_id and parent_id as well as a couple of other fields, because that’s how I wanted the categories created by users to be. Also, I’m certain there’s a better way to get the next cat_id for the query than using this ridiculous SQL query:

SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name=‘exp_categories’ AND TABLE_SCHEMA=‘your_db_name’ ORDER BY Auto_increment DESC LIMIT 1”);

If you know of a better way, let me know - I’m all ears. In the query, be sure to replace “your_db_name” with your actual database name.

Needless to say, be careful where you use this: you don’t want a spam bot or malicious user coming through and adding a bunch of junk to your categories table.


Posted on Nov 14, 2009 - 07:24 PM

Freelance Invoice Templates

A friend of mine just asked me to send him the invoice template I use for my freelance web development work. I did that, and decided that I might as well share my invoice templates with everyone else, too!

I’ve cleaned them up a bit, and they’re available in .odt and .doc format. This template is in portrait format - I have the same template in landscape format that I can put up later if you’d like.

These templates are free for you to use in any way you see fit, with or without attribution, and for private, non-profit and personal use.

Freelance Invoice Template .ODT .doc

Download here

.ODT invoice template
.doc invoice template
.PDF invoice template (not editable)

Edit 10/29/09: User sharkd from Reddit turned my template into an editable PDF. A download link is available here

If that download link doesn’t work, I’ve made a copy of it here:

Editable invoice .pdf


Posted on Oct 28, 2009 - 10:18 PM

Creative Commons Quercus Lobata/Valley Oak Leaf Scans

I’m doing a website project for my grandfather, Robert Edminster - once I finish it, I’ll be sure to mention it here. To make a long story short, the design involved an oak leaf motif. So, I went outside, picked a small branch from the Valley Oak outside, and scanned them three of the oak leaves that were in the best shape. I’m releasing the original source image as well as a couple of edited/cleaned-up versions of the original image.

I believe these are leaves from a Valley Oak, Quercus lobata, but I could be wrong.

You can download all of the derivations I made of the original scanned image, including the original image and a transparent PNG GIMP .xcf file, here, in a .zip file: oak leaves zip. As well, here are the individual files:

image


Oak Leaf Original


Oak Leaf Transparent Background PNG


Oak Leaves Lightened Original


Oak Leaves Light Background Tile


Oak Leaf Light Background Single

And a single oak leaf, GIMP .xcf source.

Feel free to use these for any project, commercial or non-commercial, under the Creative Commons Attribution-Share Alike 3.0 Unported license. All I ask is that you send me an e-mail letting me know if you do so.


Posted on Sep 25, 2009 - 12:07 AM

Mugshot Mosaics

While doing research for the the Busted Weekly post from a couple days ago, I came across a whole bunch of mugshots - thousands of them. They’re all taken from the Kent County Inmate Lookup page. At the time, I downloaded a bunch of them, sure that I could find something interesting to do with them in the future.

I have. Using a piece of software called Metapixel, I turned all of those mugshots in to mosaics.

Thinking of possible subjects for a mugshot mosaic, my first thoughts were of crime, punishment, prisons, etc. I made the following mosaic, based on ethomsen‘s Flickr photo of the Salem Jail in Salem, Massachusetts.
image  image

Then I realized that prison mosaics were too… tasteless, I guess. It seems like something Busted Weekly would do. After all, the people whose mugshots I used for the jail mosaic weren’t yet convicted of any crimes: they were just arrested. They won’t spend any time in prison until/if they’re actually convicted for the crime they were arrested for.

I decided to use Jesus as the subject for my mugshot mosaics. It makes sense, I think: Jesus was arrested often for preaching the Word, and would have had the 1st century AD equivalent of a police mugshot. As God’s children, we all have a little bit of Jesus inside of us. Also, every single person on Earth, whether we have mugshots or not, was made in God’s image.

image  Jesus Manuscript

Click on the mosaic for a 1/7 scale version. The mosaic directly above is called “Christ In Majesty,” and is taken from a page from the Stavelot Bible page on Wikipedia. The original image is 13,000 pixels tall, and 294 MB. I also have a 3,500 pixel version.

You can download the mugshots that I used in zip format (125MB download) or bzip2 format (122MB download). I used Metapixel on Linux to make these mosaics: iMosaic is supposed to work well on Linux and Windows, although I haven’t tried it.

Let me know what you think about these. This is my first time making mosaics: I haven’t yet tried tweaking the mosaics at all yet for increased clarity or better color.


Posted on Dec 02, 2008 - 02:16 PM