scriptygoddess

24 Jan, 2009

Joomla vs WordPress

Posted by: Jennifer In: Joomla|WordPress

I've long been a fan of creating non-blog sites using WordPress and pushing it's content management abilities to its maximum. However, I'm about to develop a site that could involve at least a hundred pages. This has been one of the issues I've had with WordPress when used as a CMS – it's "page management" could be better. I'm really not sure why they don't – but Pages should have categories too. If for no other reason to make it easier to navigate the backend. I mean, imagine this upcoming project – if the site has 100 pages – that's a LOT of pages to sort through in WordPress. While you can do a search for the page you want to modify – that's still kind of a painful way to do it. It would be great if you could either collapse/expand the "parent" pages – ie if 20 pages are under a parent page – hide those "children" pages in the admin – and let me drill down parent to child to child etc to find the page I need (instead of paging through 1 by 1 of ALL the pages listed in the site). AND OR – if the pages are categorized – then let me filter the view by category.

If/when WordPress gets those features – I'll have no problem recommending WordPress as the CMS for a project like I have. But since that is not currently the case, I went in search for something that was a "true" CMS.
Read the rest of this entry »

15 Jan, 2009

WordPress wp_list_comments()

Posted by: Jennifer In: Bookmarks

I haven't done too much with WordPress 2.7 until very recently. I was really surprised to see the new way of doing comments. The good news is that wp_list_comments() will list all comments, with threading, and nested replies, all by it's little self. You can turn the nested replies thing on/off from the Settings->Discussion page in the admin.

The bad news is that it spits out all the HTML, whether you like its HTML or not. I was reading on the forums the point of doing it this way was to make everyone control the "look" using styles and you "shouldn't need to change the HTML". What you "shouldn't" need to do has been the argument in favor of most issues I have with WordPress. (Don't get me wrong I do love it.) If all anyone needed to do was just change stylesheets, then everyone's HTML would look the same, because we're all doing the same thing, right? Well, we're not. Half the time I use WordPress for standard blogs – where – sure the "default" HTML is fine and I'll make it work from the styles. The other half of the time, I'm twisting WordPress to do all kinds of funky sites. Following this path of "you shouldn't need to do that" is going to start making that flexibility disappear. Applications "shouldn't" need to spit out HTML. I certainly support WordPress' idea of making it easier to use for the common person – but workarounds should always exist for those of that need a more advanced level of control. On the forums, I saw a perfect, simple reason why someone might want to change the HTML…What if I don't want it to say "blahblah says:". wp_comment_list should include parameters to change some of the hardcoded text like that…Okay. Stepping off my soapbox now. :)

Thankfully, there IS a way around it. I wish this page had more information, but it's enough to get started at least. On the wordpress codex – you can see the wp_list_comments() function explanation. (Are the three parameters the only ones wp_list_comments() takes?)

Ironic that the first thing they show you is how to bypass the "auto html dump" the function does… so if you want to customize the HTML, call the function like this:

<ul class="commentlist">
<?php wp_list_comments('callback=mytheme_comment'); ?>
</ul>

Then create a functions.php file in your theme directory and use this as a start to customize the HTML of the output:

function mytheme_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="comment-author vcard">
<?php echo get_avatar($comment,$size='48'); ?>
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>"><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ',’’) ?></div>
<?php comment_text() ?>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
</div>
<?php
}

There is a note that says there is no ending "li" tag because wordpress will automatically add that itself. (WHY OH WHY?!) I assume if you don't want it to do comments as list items and instead want divs (and therefore end with "/div" instead of "/li"), then you'd change the call to wp_list_comment to:
<div class="commentlist">
<?php wp_list_comments('style=div&callback=mytheme_comment'); ?>
</div>

There is also a comment on the "callback" parameter on the codex: "Use to customize comments display for extreme changes to the HTML layout. Not recommended." Ah. I feel like such a rebel.

A few side notes:

If you're going to use comment threading, paging, etc then this page has some useful info on it on some important things you'll need in your theme files.

And if you are going to keep the default HTML – then you'll probably need to know WHAT STYLES you need to work with! Here is the list.

This page also has some comment styling information on it.

Here is information on the new way to separate pings from comments.

14 Jan, 2009

Color Tool

Posted by: Jennifer In: Color Tool Bookmarks

Here's another color tool to add to the list

HSL Color Schemer

Truth be told, I was sent that link too long ago to mention without being embarrassed. It's been sitting in my to do box to post the link since then. Doh!

Comments Off on Color Tool

14 Jan, 2009

Turn off WordPress Post Revisions

Posted by: Jennifer In: Bookmarks

I know wordpress people believe making this an option is bad, but I really really wish they would. Make an "advanced" settings section that you have to turn on with your profile if need be. Whatever it is – this should be in the UI. In any case, I always have to do this, and I always forget the exact syntax. I think many places published it – I've probably seen it at least a dozen times. Just now when I was searching for it I found it here. But because I need to have the code handy here's the beef:

(add this to the wordpress config file after the "DB COLLATE" line.
define ('WP_POST_REVISIONS', 0);
define('AUTOSAVE_INTERVAL', 600);

This sql query will remove the revisions from the database:
DELETE FROM wp_posts WHERE post_type='revision';

Go to the abeontech link for more details.

13 Jan, 2009

Reg Ex samples

Posted by: Jennifer In: Regular Expressions

I've been reading up on Reg Ex and just STARTING to get my head around the subject. One use I've found for it immediately is with Dreamweaver. (Dreamweaver has a "regular expression" search option). Just for my own future re-use and storage – I'll post a few I've used. (Will probably/hopefully add to this post over time…)

<td><a href=["].+["] target=["]_blank["]></a></td>
searches for
<td><a href="ANYTHING CAN GO HERE" target="_blank"></a></td>

<[/]*tr>
searches for
<tr> and </tr>

To replace only PORTIONS of what you find –
search for:
<td><a href=["](.+)["] target=["]_blank["]>
and then you can replace lit like this
<td><a href=["]$1["]>
(will "save" anything it found with (.+) and keep it in the replace with $1

Used this one today (6/5/09) – had to find spaces in a query string and replace it with %20
(pagename.php[?]m=\S[^"]*)[\s]
That will find pagename.php?m=anything except the ending quote
It stores everything except the space (should be the last one in the query string) in $1 so you can do a replace with:
$1%20

New one (8/14):
<!–.+–>
That will find all the comments on the page (again this is in dreamweaver)

Updated 7/26:
\?\>\s$$
Finds a file with space after ?> at the end of the file.

13 Jan, 2009

Google Ads are back…

Posted by: Jennifer In: Announcements

Yes. I'm selling out. I still have issues with Google, but whatever.

It's been a while since I made a plea for help on here. But this time I'm really stumped.

Here's the short story:
A brand new clean install of wordpress – no plugins, no posts even except the default post. No funky characters in the blogs name. As plain vanilla as you can get. Run a search that BEGINS with the letter "d" and it hangs.

I thought it might be a wordpress 2.7 issue, so I tried installing an older version of wordpress. Nope. Same problem.

In this case the hosting is a dedicated virtual server account with Media Temple. (for a client). I have other clients hosted on Media Temple (different accounts) that run wordpress and none of them are having this problem.

There was a workaround posted on the support forums, basically in the search form tag I changed it from this:
<form method="get" action="<?php bloginfo('url'); ?>/">
to this:
<form method="get" action="<?php bloginfo('url'); ?>/index.php">

and magically it works. But doesn't that seem kind of strange. Any other search went through fine – why the letter "d". And what's also strange is that Media Temple support reps did NOT have this problem – not unless they used a proxy server. ?!?!

I've had a few clients ask for this, and I saw some requests to do this on the forums, but no one ever that I found came up with a solution. Here's the scenario, you have your blog posts, and maybe they're long, and rather than make the page *even longer* by dumping the comments on the same page at the bottom, you want a special, separate page for the comments for each post.

Now the trick I've done to accomplish this, I will warn you worked in the scenario it was designed in – (I had "permalinks" turned on. I'm not sure how this would work, if at all, if they weren't turned on, or if the permalink configuration was different) I'm sure there are probably other setups where this would not work. So, that's my disclaimer.

Basically what we're going to do is use the query string to determine whether or not to display comments or the post on the page. It's not terribly "pretty" – and maybe a htaccess expert can tell us how to accomplish the same task by adding a line or two in there to keep the URLs "pretty" – but in the meantime, I'm just happy to have it work at all!

So first – surround anything you would want only on the POST version of the page with this:
*UPDATED TO ADD: This problem/question has come up a number of times. These changes will probably go on your single.php template file (because thats the page that normally dispalys the comments.) If for some reason you don't have a single.php file, then your "single-post view" is probably being derived from the default single.php template file (in the default theme directory) – so it's probably safe to grab a copy of that one and make your changes to it, and then upload it to your theme's directory)

<?php if (!isset($_GET['show'])) { ?>
POST PAGE ONLY STUFF GOES HERE...
<?php } ?>

*ALSO UPDATED TO ADD:The code above should be WITHIN the "WP LOOP".

Inside there you will want to create a link that will bring the user to the "comment page" for the post. You do that like this:

<a href="?show=comments">Click here to view/write comments</a>

Then you wrap your call to the comments template like so:

<?php if (isset($_GET['show']) && $_GET['show'] == "comments") { ?>
<?php comments_template(); ?>
<?php } ?>

*UPDATED TO ADD: Take a look at where the comments_template() line normally goes on the default theme, if you're using a custom theme. You want to make sure you really only put that around the comments_template() line… not large sections of your single.php template file…

Now, ON your comments template page (comments.php), you will need to modify the comments form so that after a comment gets submitted, you end up back on the comment version of the page. To do that you need to grab the current URL of the page you're looking at – and put it into a hidden field (named "redirect_to") in the comment form. To get PHP to pull in the full URL, I grabbed this function from webcheatsheet.com:

function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}

To make that available throughout, I created a "plugin" file, and just threw that function into it. (obviously have to activate the plugin before you can start using that function in your theme). (There's probably another way to "add a function" like that, but this worked for me) If you don't already have one, create a "functions.php" file for your theme and add that function in there (surrounded by <?php and ?> tags obviously)

So then before the </form> of the comment form I added this:

<?php if (function_exists('curPageURL')) { ?>
<input type="hidden" name="redirect_to" value="<?php echo curPageURL() ?>" />
<?php } ?>

That's it. Hope that helps someone else. :)

Updated:
Here are the modifications applied to the default wordpress theme. I've made comments to the changes I added in so you can see what I did and then apply it as appropriate to your own theme. In the zip are JUST the files I modified – not the whole wordpress default theme – so single.php, index.php, functions.php and comments.php.

01 Oct, 2008

Repeating backgrounds and IE

Posted by: Jennifer In: CSS related

There's probably a really good reason for this (actually, wait. We're talking about IE. Nevermind) 😉

Just wanted to post a reminder to myself should I ever come across this weirdness again. I was working on a layout recently, and everything was working fine in Firefox, and everything was fine in IE except for one little nagging problem. A box that had a repeating background image in it sometimes showed up with the background in IE, and then sometimes not. Sometimes if I refreshed the page – suddenly the background image appeared. The line in my css calling for the background image looked like this:

#mybox {
background: url(images/my_background_tile.jpg) top left repeat-y;
}

Everything looks kosher – at least it SHOULD be. For some reason IE REALLY wanted a background color too! (even though it wouldn't be showing up because the image would be covering over it). Okay. Whatever. So this is what made the background image show up consistently:

#mybox {
background #fff url(images/my_background_tile.jpg) top left repeat-y;
}

IE was happy. And there was much rejoicing.
(*one quick note: this problem was specific to REPEATING background images. Background images set to no-repeat were not having problems)

Oh also – don't ever do this:

#mybox {
background: #fff url(images/my_background_tile.jpg) top repeat-y;
}

All kinds of weirdness happens then. If you're going to specify background coordinate locations (with either "top", "left", "5px", etc.) you have to specify both x and y locations. IE will hate you otherwise. And we don't want THAT! do we?

20 Sep, 2008

Overlapping Tabbed Navigation using CSS and jQuery

Posted by: Jennifer In: CSS|jquery

Recently had a project land on my desk that required tabbed navigation that overlap one another. Just so we're clear on what we're doing: here's the demo. Here is how I did it:

1) Each tab has four "states" – Off, Off (with right tab on), On, On (with right tab on). I combined each of these four states in the one image for each tab. So it looks like this:

2) The HTML is pretty simple and looks like this:

<div id="navbar">
<ul>
<li id="nav_home"><a href="#"><span>Home</span></a></li>
<li id="nav_about"><a href="#"><span>About Us</span></a></li>
<li id="nav_products" class="right"><a href="#"><span>Products</span></a></li>
<li id="nav_sales" class="current"><a href="#"><span>Sales Reps</span></a></li>
<li id="nav_contact"><a href="#"><span>Contact Us</span></a></li>
</ul>
</div>

Notice that when one of the tabs is set as the "current" tab – we also need to define the tab before it with a class of "right" (meaning that the tab to the right of this one is set as "on")

3) Then we define the various states in CSS. In this case, all the tabs are the same width and height:

#navbar li {
float: left;
}
#navbar li a {
display: block;
height: 29px;
width: 91px;
}

Hide the text with css since we're using images for the tabs:

#navbar li a span {
margin: 0 0 0 -100000px;
}

Define the image to be used for each tab:

#nav_home a {
background:url(images/nav_home.gif) top left no-repeat;
}
#nav_about a {
background:url(images/nav_about.gif) top left no-repeat;
}
#nav_products a {
background:url(images/nav_products.gif) top left no-repeat;
}
#nav_sales a {
background:url(images/nav_sales.gif) top left no-repeat;
}
#nav_contact a {
background:url(images/nav_contact.gif) top left no-repeat;
}

4) I'm going to skip over the rest of the class definitions and move to the jquery part – because I think it will make more sense to see how the classes are being defined if you see what class I'm applying when and where.

<script type="text/javascript" src="js/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
var j = jQuery.noConflict();
j(document).ready( function() {
j('#nav_about a').hover(function() {
j('#nav_home a').addClass("left");
}, function() {
j('#nav_home a').removeClass("left");
});
j('#nav_products a').hover(function() {
j('#nav_about a').addClass("left");
}, function() {
j('#nav_about a').removeClass("left");
});
j('#nav_sales a').hover(function() {
j('#nav_products a').addClass("left");
}, function() {
j('#nav_products a').removeClass("left");
});
j('#nav_contact a').hover(function() {
j('#nav_sales a').addClass("left");
}, function() {
j('#nav_sales a').removeClass("left");
});
});
</script>

So what I'm doing here is, anytime I mouseover a tab, I'm adding the class "left" to the <a> tag in the tab in front of the one my mouse is on.

So if the tab in front of the one my mouse is on is "off" – then we need to change that tab to state #2 (Off – with the tab next to it on). If that tab has the class "current" applied to the li tag – then we need to move that tab to state #4 – (On – with the tab next to it on).

4) So on to the various states with css….

When hovering – we go to the "on" state – (in this case, when tab is current, it lookes the same as when we mouse over it.) So the most basic state – state #3: Whether the tab is current, or hovering – move to that "Third" state: On – with the tab next door off.
#navbar li.current a,
#navbar a:hover {
background-position: 0 -58px;
}

This is for state #2: Off – with the tab next to us as On. (the ".right" class applied to the li tag means that the tab in front is "current")
#navbar li.right a,
#navbar li a.left {
background-position: 0 -29px;
}

This is for state #4 – On with the tab next to us as on.
#navbar li.right a:hover,
#navbar li.current a.left {
background-position: 0 -87px;
}

One thing to note – the last tab really only has two states – because there is no tab in front of it – but to keep things simple in the code and css – I just made the image with the extra versions. This way it could have the same styles applied to it – without having to make a special case for it.

Here are some more demos:

No tab set as current

Home tab set as current (no "right" class needs to be applied – since home is the first tab)

Last tab set as current

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements