Content

Visual communicator / logbook & brain bin

Slug as string in WordPress – the_slug();

Thursday 15 July 2010 - Filed under Wordpress

I needed a way to replace the default page ID in WordPress with the page slug, and discovered this two year old post in the support forums.

Put this function in your functions.php:

function the_slug() {
	$post_data = get_post($post->ID, ARRAY_A);
	$slug = $post_data['post_name'];
	return $slug;
}

And call it in your template file like this:

<article id="<?php echo the_slug(); ?>">

Simple as that; saves you from writing CSS for randomly numbered IDs.

Tagged: » »

3 comments  ::  Share or discuss  ::  2010-07-15  ::  Asgeir

List titles within the list element

Tuesday 29 June 2010 - Filed under HTML5

Why don’t lists allow a list title child element? It makes perfect sense semantically, and it would save the extra wrapper <div> every time the designer needs to position a titled list.

Valid HTML, with the title separated from the list element:

<div class="mylist">
<h2>List title</h2>
<ul>
<li>Proin convallis fermentum leo, at elementum enim dapibus sed.</li>
<li>Quisque dictum ligula massa, eget convallis tellus.</li>
<li>Nulla et purus ut nisi cursus posuere nec pretium elit.</li>
</ul>
</div>

My suggestion, with a new list title child element:

<ul class="mylist">
<lt>List title</lt>
<li>Nunc aliquam nunc quis turpis laoreet pretium.</li>
<li>Aliquam et tortor quis massa rutrum commodo.</li>
<li>Donec quis sapien ac justo fringilla fermentum cursus sit amet velit.</li>
<li>Aliquam pulvinar rutrum nisi, a congue lacus blandit quis.</li>
</ul>

Why not?

Tagged:

2 comments  ::  Share or discuss  ::  2010-06-29  ::  Asgeir

I might be inactive, but sand maker is not!

Monday 19 April 2010 - Filed under General

The few times that I log in to this thing, I find myself enjoying the increasing amount of great comments. Sand maker thinks that the..

..Permalink Article write great, I think all read this article people would think so. I from China, I seen article, really beautiful, great. I like article feeling good. I will continue concern here.

..as opposed to my good friend Daniel Depp, who is unhappy with my tone, and is yet to durchgerungen:

I can only speak for myself: I find your articles are packed too sober and too long. When I had seen it, I had no desire to read it (but I’ve yet to durchgerungen). Furthermore, I am interested in the topics of your article is not particularly. Too bad. Nevertheless, I hope for you, of course, to more comments. Besides that, this is also one!

And, my other friend funny, knows where to get CSS classes on DVD:

i do not know much about CSS ,but i learnt some in my collegeTv series on DVD ,i think it is very difficult to learn it well .it is so hard .And i am poor in learning computerDVD Collection too .It is my pity i did not grasp the computer skills before .

Tagged:

1 comment  ::  Share or discuss  ::  2010-04-19  ::  Asgeir

Custom radio inputs using pure CSS

Wednesday 24 February 2010 - Filed under CSS + Web design

Ryan Seddon, also referred to as the CSS Ninja, has created some impressive custom radio and checkbox inputs with pure CSS. The technique, which he posted late last week, is using some nifty selectors and pseudo-madness to detect input state, and swap the original inputs with images from a sprite.

The new inputs are actually attached to the label tag, rather than to the input itself, using the :before pseudo-class. The :hover, :focus, :active, and the :disabled classes are all used, in order to achieve full control over all possible states. So far, it looks like it degrades nicely in older browsers, falling back to the default inputs. It doesn’t require any additional markup, and it even lets you navigate the forms with the keyboard.

The only thing I noticed is that it seems like the bottom third or so of the checkbox doesn’t actually respond to a click, and the click zone stretches above the input correspondingly.

Have a look at the demo.

Well done!

Tagged:

 ::  Share or discuss  ::  2010-02-24  ::  Asgeir

DOM Scripting by Jeremy Keith

Sunday 21 February 2010 - Filed under Web design

I have been dabbling with Javascript a few times, but only at the level where I was stoked when I could create a function to convert fahrenheit to celsius. I was going to try to make a slightly more serious attempt at learning it, and bought DOM Scripting: Web Design with Javascript and the Document Object Model by Jeremy Keith of Clearleft.

Javascript has restored its name the last few years, after having lost all credibility as a serious tool due to browser wars, the DHTML disaster, pop-up dialogues and open-CD-tray scripts. Jeremy Keith sees javascript as a necessary scripting language that completes the front-end development toolkit, together with CSS and (X)HTML. Unobtrusive javascripting, unobtrusive being the keyword, offers an equal level of power to what CSS once did, when used correctly.

As for the target audience, this book was exactly what I was after:

The book is aimed at designers rather than programmers. If you’ve learned the benefits of Web Standards through CSS and you’re now ready to move on to the next level, this is the book for you.

DOM Scripting clearly introduces all the concepts that would be unfamiliar to a a non-programmer, and provides a solid history of the developments the last 10-or-so years, before diving into any scripting. Chapter two is a thorough explanation of the javascript syntax, with some half-practical examples. Next is the Document Object Model, and that’s where I’m at.

Tagged: »

1 comment  ::  Share or discuss  ::  2010-02-21  ::  Asgeir