scriptygoddess #page { background: url("http://www.scriptygoddess.com/wp-content/themes/default/images/kubrickbgwide.jpg") repeat-y top; border: none; } scriptygoddess Scriptygoddess Forums August 13th, 2008 Just wanted to post that I’ve created a forum for shopping carts, scripts, etc. here:scriptygoddess.com/discussionI’ve just started filling some forums/categories in there - so if you want to see a specific forum for something - let me know. I thought it might make sense to create a forum for topics that needed more of a discussion - something that I didn’t think was as easily accomplished with single threads in a blog post… Anyway, hopefully it will be useful and helpful. We’ll see how it goes. digg_url = 'http://www.scriptygoddess.com/archives/2008/08/13/scriptygoddess-forums/'; digg_title = 'Scriptygoddess Forums'; digg_bodytext = 'Just wanted to post that I\'ve created a forum for shopping carts, scripts, etc. here:scriptygoddess.com/discussionI\'ve just started filling some forums/categories in there - so if you want to see a specific forum for something - let me know. I thought it might make sense to create a forum for topics that needed more of a discussion - something th'; Posted in Announcements | No Comments » Show full post if there is no excerpt July 24th, 2008 As the title said - needed to show the excerpt if there was one, or the *full* post if there wasn’t (not the shortened version wordpress “fakes”)remove_filter('get_the_excerpt', 'wp_trim_excerpt');if (get_the_excerpt() == "") {echo apply_filters('the_content',get_the_content());} else {echo apply_filters('the_content',get_the_excerpt());echo '<p><a href="http://www.scriptygoddess.com//".get_permalink().'">Read more...</a></p>';}Updated 8/11/08 Made some changes to the code. Excerpts were coming in unformatted, also removed some extra stuff I don’t think I needed in there… digg_url = 'http://www.scriptygoddess.com/archives/2008/07/24/show-full-post-if-there-is-no-excerpt/'; digg_title = 'Show full post if there is no excerpt'; digg_bodytext = 'As the title said - needed to show the excerpt if there was one, or the *full* post if there wasn\'t (not the shortened version wordpress \"fakes\")remove_filter(\'get_the_excerpt\', \'wp_trim_excerpt\');if (get_the_excerpt() == \"\") {echo apply_filters(\'the_content\',get_the_content());} else {echo apply_filters(\'the_content\',get_the_excerpt()'; Posted in Bookmarks | 4 Comments » Moving a Wordpress Install June 14th, 2008 One of my clients recently purchased new servers and wanted to migrate all their sites to the new servers. Some of these sites were wordpress powered. Thankfully, I found this article that made the move a breeze.The critical thing I want to save for my future reference is the following sql lines from that post:UPDATE wp_options SET option_value = replace(option_value, 'http://www.old-domain.com', 'http://www.new-domain.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');See the post on My Digital Life for the full instructions digg_url = 'http://www.scriptygoddess.com/archives/2008/06/14/moving-a-wordpress-install/'; digg_title = 'Moving a Wordpress Install'; digg_bodytext = 'One of my clients recently purchased new servers and wanted to migrate all their sites to the new servers. Some of these sites were wordpress powered. Thankfully, I found this article that made the move a breeze.The critical thing I want to save for my future reference is the following sql lines from that post:UPDATE wp_options SET option_value = r'; Posted in WordPress, WordPress Hacks | 1 Comment » Get Wordpress to use sendmail instead of mail() June 3rd, 2008 Same project I just mentioned below - something funky was going on with Wordpress not sending emails. I had a server admin looking at the server and I’d submit a comment on the corporate blog and no emails would get sent. I even tried using a plugin that forced wordpress to use SMTP, still would not send emails from the blog.I found on the support forums where someone mentioned a hack to get Wordpress to use sendmail. In wp-includes folder open the file pluggable.php. Around line 362 is the following:// Set to use PHP's mail()$phpmailer->IsMail();Change that to:// Set to use PHP's mail()//$phpmailer->IsMail();$phpmailer->IsSendmail();As soon as I did that - voila - it started sending emails.(yes, I know, I’m modifying core code again. Tell me how to make this a plugin and I will!) digg_url = 'http://www.scriptygoddess.com/archives/2008/06/03/get-wordpress-to-use-sendmail-instead-of-mail/'; digg_title = 'Get Wordpress to use sendmail instead of mail()'; digg_bodytext = 'Same project I just mentioned below - something funky was going on with Wordpress not sending emails. I had a server admin looking at the server and I\'d submit a comment on the corporate blog and no emails would get sent. I even tried using a plugin that forced wordpress to use SMTP, still would not send emails from the blog.I found on the support'; Posted in WordPress, WordPress Hacks | 1 Comment » Pulling in post content from a separate blog install June 3rd, 2008 I had a site I was using Wordpress for - and it actually involved two separate installs. One install was set up as the main content management for the site. Pages were obviously the pages of the site. Posts were for news and Press Release articles. A separate install was for the “corporate blog.”I had one page where I listed the news and PR items, and I was asked to also list the latest blog posts on that page as well. Since the blog was actually an entirely different install, this presented the problem. The critical issue here is that both Wordpress installs are in the same database - just with different prefixes. This makes the problem pretty easy to deal with.So just to go over the other aspect of the page - listing the news and Press Releases - that is simple. I get the id of the categories (lets say that news has an id of ‘5′ and PR has and id of ‘6′) on the page template I create especially for that page I have the following:<h3>News</h3><?php global $post;//category=5 - this is the id for news $myposts = get_posts('numberposts=5&category=5'); foreach($myposts as $post) : ?> <p><a href="http://www.scriptygoddess.com//<?php" the_permalink(); ?>"><?php the_title(); ?></a><br /> <em><?php the_time('F jS, Y') ?></em></p> <?php endforeach; ?><h3>Press Releases</h3><?php global $post;//category=6 - this is the id for Press Releases $myposts = get_posts('numberposts=5&category=6'); foreach($myposts as $post) : ?> <p><a href="http://www.scriptygoddess.com//<?php" the_permalink(); ?>"><?php the_title(); ?></a><br /> <em><?php the_time('F jS, Y') ?></em></p> <?php endforeach; ?>Now to pull in the post content from the other blog - you need to a swap in the prefix you’re using for the other install (where I have “BLOGPREFIX” below). Also had to manipulate the URL given by “get_permalink()”. See my note below in the code.<h3>Blog Posts</h3><?php$querystr = "SELECT * FROM BLOGPREFIX_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC limit 5";$blogposts = $wpdb->get_results($querystr, OBJECT);if ($blogposts): ?><?php foreach ($blogposts as $post): ?><?php setup_postdata($post); ?><?php /*Normally you use the_permalink() to display the URL -but that would show the post as if it was part of thecurrent blog. In my case, the blog was actually set upas a subdomain. There may be a better way to do this butI just stripped out the domain and replaced it with theblog's subdomain. See below */$newpermalink = str_replace("http://www.MYDOMAIN.com","http://BLOG.MYDOMAIN.com",get_permalink()); ?><p><a href="http://www.scriptygoddess.com//<?php" echo $newpermalink; ?>"><?php the_title(); ?></a><br /><em><?php the_time('F jS, Y') ?></em></p><?php endforeach; ?><?php else : ?><p> Not Found</p><?php endif; ?>That will pull the last 5 blog entries - with the title linked to the post and the date below it. digg_url = 'http://www.scriptygoddess.com/archives/2008/06/03/pulling-in-post-content-from-a-separate-blog-install/'; digg_title = 'Pulling in post content from a separate blog install'; digg_bodytext = 'I had a site I was using Wordpress for - and it actually involved two separate installs. One install was set up as the main content management for the site. Pages were obviously the pages of the site. Posts were for news and Press Release articles. A separate install was for the \"corporate blog.\"I had one page where I listed the news and PR items'; Posted in WordPress, WordPress Hacks | 2 Comments » Proportional Scaling Calculator May 13th, 2008 I’m sure this has been done before since it’s pretty simple - I just couldn’t find it quick enough when I needed it. And since it is so simple, it was easier to just create my own personal little calculator than dig around, find one, bookmark. (or worse yet, do the math on a little sticky note next to my computer) ;PThis calculator will let you enter in the original width and height of an image (or document, video or whatever). Then you enter the width (or height) of the size you need it scaled to (down or up). And it will tell you what the other side needs to be.For example: I have an 800×600 image - I need it scaled down to fit in a 256 width area… what height will I need to make it? This tool will answer your question.Proportional Scaler Calculator digg_url = 'http://www.scriptygoddess.com/archives/2008/05/13/proportional-scaling-calculator/'; digg_title = 'Proportional Scaling Calculator'; digg_bodytext = 'I\'m sure this has been done before since it\'s pretty simple - I just couldn\'t find it quick enough when I needed it. And since it is so simple, it was easier to just create my own personal little calculator than dig around, find one, bookmark. (or worse yet, do the math on a little sticky note next to my computer) ;PThis calculator will let you '; Posted in Javascript, Scripts | 3 Comments » Phone number validation with jquery May 3rd, 2008 One of the things I’ve been playing around with a lot recently is jquery. Why I didn’t jump on this bandwagon sooner, I’m not sure, but I am kicking myself for it. So I am still a bit of nub on the jquery front - but I like to think I pick things up quickly. So one thing I am now using jquery regularly for is form validation. Previously, form validation used to mean a lot of script writing, not to mention a fair amount of dread.Now it’s quite painless.My current usage of that plugin is pretty basic until I get a better handle of it. But one thing that I have been requested a number of times, is to add validation for a phone number - which is not included in that plugin. I’m not sure this is the “right” or best way to do it - but it does work. The functions are basically the same as those provided here with some minor modifications and altered to be used with the jquery plugin.First of course you include the jquery javascript file:<script language="javascript" type="text/javascript" src="http://www.scriptygoddess.com//js/jquery.min.js"></script>Then the validation plugin:<script type="text/javascript" src="http://www.scriptygoddess.com//js/jquery.validate.pack.js"></script>Then you add the function to check the phone number:<script type="text/javascript">$.validator.addMethod("phone", function(phone_number, element) {var digits = "0123456789";var phoneNumberDelimiters = "()- ext.";var validWorldPhoneChars = phoneNumberDelimiters + "+";var minDigitsInIPhoneNumber = 10;s=stripCharsInBag(phone_number,validWorldPhoneChars);return this.optional(element) || isInteger(s) && s.length >= minDigitsInIPhoneNumber;}, "Please enter a valid phone number");Some “helper” functions:function isInteger(s){ var i; for (i = 0; i < s.length; i++) { // Check that current character is number. var c = s.charAt(i); if (((c < "0") || (c > "9"))) return false; } // All characters are numbers. return true;}function stripCharsInBag(s, bag){ var i; var returnString = ""; // Search through string's characters one by one. // If character is not in bag, append to returnString. for (i = 0; i < s.length; i++) { // Check that current character isn't whitespace. var c = s.charAt(i); if (bag.indexOf(c) == -1) returnString += c; } return returnString;}Then the line that makes the jquery run:$(document).ready(function() { $("#myform").validate();});</script>To use the jquery validation plugin - I was just adding “required” as a class to those fields that were required. Like this:<input type="text" name="FirstName" class="required" />You can check email structure by also adding the class “email”.<input type="text" name="EmailAddress" class="required email" />And now, using the code above, if you add the class “phone” - it will check a phone number.<input type="text" name="PhoneNumber" class="required phone" />(My code above allows for some additional characters beyond just numbers - so that it will accept parens around the area code - dashes or periods between the numbers and “e” “x” “t” characters as well - in case someone needs to include an extension.)Typical disclaimer - like I said - I’m still a nub at jquery. There may be a better/easier way to do the above, so as always feel free to chime in if you know what that better/easier way is…Updated 5/5/08 I do see a “phone” method in the “additional-methods.js” file… but I needed it do things a little differently… (like allowing extension numbers etc.)Updated 5/29/08 Had some issues with the method not allowing phone fields to be optional and only checking the values if something was entered (when optional). Fixed that now.Updated 7/1/08 As JT noted in the comments with regex this can be simplified. JT provided the following code:function isValidPhoneNumber(ph) { if (ph == null) { return false; } var stripped = ph.replace(/[\s()+-]|ext\.?/gi, “”); // 10 is the minimum number of numbers required return ((/\d{10,}/i).test(stripped));}So to update the jquery:$.validator.addMethod("phone", function(ph, element) {if (ph == null) { return false; } var stripped = ph.replace(/[\s()+-]|ext\.?/gi, “”); // 10 is the minimum number of numbers required return ((/\d{10,}/i).test(stripped));}, “Please enter a valid phone number”);And then you can loose the other “helper” functions. (Thanks JT!!) digg_url = 'http://www.scriptygoddess.com/archives/2008/05/03/phone-number-validation-with-jquery/'; digg_title = 'Phone number validation with jquery'; digg_bodytext = 'One of the things I\'ve been playing around with a lot recently is jquery. Why I didn\'t jump on this bandwagon sooner, I\'m not sure, but I am kicking myself for it. So I am still a bit of nub on the jquery front - but I like to think I pick things up quickly. :DSo one thing I am now using jquery regularly for is form validation. Previously, form '; Posted in Javascript, jquery | 8 Comments » Suckerfish Dropdown navigation going behind content May 3rd, 2008 Awhile back, I had a project where I created a nice clean (X)HTML page including navigation using UL and LI tags. A few months later the client decided they wanted to add a dropdown menu to the navigation. No problem, I thought. We just add the embedded lists to the navigation - style it with CSS - and use the Suckerfish dropdown menu technique. Easy Peasy.Except when I implemented it, the drop down menus were showing up BEHIND the rest of the content instead of “above/over it”. There was a lot of other things going on in the page, I have a simple example that demonstrates the issue.I’m sure it makes sense somehow, if I had a better grasp of what “position: relative” does to the document - beyond that “position: relative” allows items INSIDE a relatively positioned block to be absolutely positioned WITHIN it (which is why I had done that). The side effect though is that it does that crazy thing with the menu.Oh the HOURS and HOURS to figure that out…. /sigh.Here is the same page - with just that one line (position: relative) removed.I’ve now seen this problem crop up a few times. In one case, I was working with a design that I had not originally created and even though there were no “position: relative” in any of the css files - the only way to get the menu to be ABOVE the content was to explicitly declare “position: static” inside the div tag itself. (Even just declaring it in the css wouldn’t fix it - somewhere else it must have still been getting overridden)While I’m at the point where I can’t even imagine designing a page using a table based layout anymore, I still get hit with some CSS sticking points that I just don’t get. So if you have more insight on this feel free to elaborate in the comments. I’m just so glad I was able to get the menu working! digg_url = 'http://www.scriptygoddess.com/archives/2008/05/03/suckerfish-dropdown-navigation-going-behind-content/'; digg_title = 'Suckerfish Dropdown navigation going behind content'; digg_bodytext = 'Awhile back, I had a project where I created a nice clean (X)HTML page including navigation using UL and LI tags. A few months later the client decided they wanted to add a dropdown menu to the navigation. No problem, I thought. We just add the embedded lists to the navigation - style it with CSS - and use the Suckerfish dropdown menu technique. Ea'; Posted in CSS, Javascript | 9 Comments » Submit is Not a Function (and getting links to submit all forms in CubeCart) March 15th, 2008 “Why am I getting that Javascript error?? WTH is it talking about - submit IS a function!!”So here’s the deal - if you have a form and an element in the form is named “submit” - if you try to call document.myform.submit() - you’ll end up getting the “submit is not a function” javascript error. (Because to javascript - “submit” is now that object element in your form - not a function)So the simple solution is if you plan on using the javascript function submit() - do not name any of your form elements “submit”.That’s all well and good except if you’re working on code that isn’t completely yours - and if the PHP code to process the form is specifically looking for $_POST['submit'] like so:if (isset($_POST['submit'])) { // process form }then you now have another problem.This was the case I ran into with CubeCart recently. Most of the forms do not require a submit element to be in the form in order to process it - but a handful did. The design I was working on needed all the buttons designed and to look the same. So my options were:1) Just use the regular input type=”submit” button on those forms. (Ok - but then the site is inconsistent)2) search for all instances of (isset($_POST['submit']) in the code and change it to some other element I can add to the page… ie:<input type="hidden" name="formsubmitted" />and then in the code:if (isset($_POST['formsubmitted'])) { // process form }(Obviously this is not recommended in the case of CubeCart as it will make it really annoying to maintain/upgrade the cart!)3) add that other “formsubmitted” element I noted above to the pages that need it - then towards the top of the MAIN index.php page (which is called with all pages on the store) add the following:if (isset($_POST['formsubmitted'])) $_POST['submit'] = 1;Thereby setting the value of $_POST['submit'] so it will process the form…Another tip with using css-styled links for buttons that will submit forms in CubeCart - you don’t need to use document.FORMNAME.submit() - from any form you can use their “submitDoc(’FORMNAME’)” function like so:<a href="javascript:submitDoc("FORMNAME');" class="myButtonStyle">Send Form</a>Just make sure the form has a name (some of them don’t). digg_url = 'http://www.scriptygoddess.com/archives/2008/03/15/submit-is-not-a-function-and-getting-links-to-submit-all-forms-in-cubecart/'; digg_title = 'Submit is Not a Function (and getting links to submit all forms in CubeCart)'; digg_bodytext = '\"Why am I getting that Javascript error?? WTH is it talking about - submit IS a function!!\"So here\'s the deal - if you have a form and an element in the form is named \"submit\" - if you try to call document.myform.submit() - you\'ll end up getting the \"submit is not a function\" javascript error. (Because to javascript - \"submit\" is now that'; Posted in Javascript Related, cubecart | No Comments » How to make a progress/goal (thermometer-like) bar graph with PHP February 23rd, 2008 On one of my projects recently, they needed a dynamic bar graph that would show the progress towards a goal of donations. I’ve never done something like that before, and it turns out it’s actually pretty simple to do. I’ll explain how the code works and then include everything at the end. Read the rest of this entry » digg_url = 'http://www.scriptygoddess.com/archives/2008/02/23/how-to-make-a-progressgoal-thermometer-like-bar-graph-with-php/'; digg_title = 'How to make a progress/goal (thermometer-like) bar graph with PHP'; digg_bodytext = 'On one of my projects recently, they needed a dynamic bar graph that would show the progress towards a goal of donations. I\'ve never done something like that before, and it turns out it\'s actually pretty simple to do. I\'ll explain how the code works and then include everything at the end.What we\'ll be doing is calling a php script into the src '; Posted in PHP | 8 Comments » « Older Entries PagesAbout Archives August 2008 July 2008 June 2008 May 2008 March 2008 February 2008 January 2008 December 2007 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 April 2007 March 2007 February 2007 January 2007 December 2006 November 2005 August 2005 June 2005 May 2005 April 2005 March 2005 February 2005 January 2005 December 2004 November 2004 October 2004 September 2004 August 2004 July 2004 June 2004 May 2004 April 2004 March 2004 February 2004 January 2004 December 2003 November 2003 October 2003 September 2003 August 2003 July 2003 June 2003 May 2003 April 2003 March 2003 February 2003 January 2003 December 2002 November 2002 October 2002 September 2002 August 2002 July 2002 June 2002 May 2002 April 2002 Categories Admin-type scripts (4) Announcements (76) babble (1) bookmarklets (2) Bookmarks (344) Color Tool Bookmarks (14) CSS related (11) FireFox Extension Bookmarks (5) Javascript Related (2) PHP Related (2) Call for help (5) complaint department (2) CSS (28) cubecart (3) Flash (1) How to's (51) htaccess tricks (1) Internet Explorer (1) Javascript (10) jquery (1) Lessons learned (60) Movable Type (57) MT hacks (52) MT Plugins (2) MT scripts (1) MT Tips n Tricks (2) mySQL (3) Outlook (1) Photoshop Tutorial (3) PHP (6) pMachine (4) product review (5) Projects (10) Scripts (115) Script snippet (34) shopping cart (2) Suggested reading (11) WordPress (93) WordPress Bookmarks (18) WordPress Bookmarks to Plugins (31) WordPress Hacks (14) WordPress my-hacks additions (5) WordPress Plugins (10) WordPress scripts (4) WordPress: Lessons Learned (11) Bookmarks ASCII Character TestSQLCourse WordPress Resources WordPress scriptygoddess is proudly powered by WordPress Entries (RSS) and Comments (RSS). sc_project=3678097; sc_invisible=1; sc_partition=44; sc_security="082c85a6"; var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");document.write(unescape("%3Cscript src="http://www.scriptygoddess.com//" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));var pageTracker = _gat._getTracker("UA-1740128-1");pageTracker._initData();pageTracker._trackPageview(); |
|