
dwest
Members-
Posts
83 -
Joined
-
Last visited
Never
Everything posted by dwest
-
Solved this by using PHP function Shuffle() Further down in the plugin code is the following which takes each item in the array and does stuff to it: if (is_array($gallery_array)) { foreach ($gallery_array as $galleryID) { $out .= nggCreateAlbum($galleryID,$mode,$albumID); } } I changed it to: if (is_array($gallery_array)) { shuffle($gallery_array); foreach ($gallery_array as $galleryID) { $out .= nggCreateAlbum($galleryID,$mode,$albumID); } } Now the albums appear in a different order each time thsy are loaded. Thanks for the help anyway cmgmyr :-)
-
Sorry! I got into the database and studied what is stored for sortorder and it is a string like this: a:8:{i:0;s:1:"7";i:1;s:1:"6";i:2;s:1:"1";i:3;s:1:"... I suppose that is an array? yes?
-
Not working. Still seems to be putting them in the order specified in the admin settings.
-
Thanks CMGMYR! Trying now. What is the significance of LIMIT? What is being limited?
-
Hi, I have a WordPress photo gallery plugin which stores the order of the photo albums based on a sort order number assigned by me in the admin settings. I want to bypass this setting and display them in random order, different each time the page loads. The code in the plugin to get the sort order is $sortorder = $wpdb->get_var("SELECT sortorder FROM $wpdb->nggalbum WHERE id = '$albumID' "); if (!empty($sortorder)) { $gallery_array = unserialize($sortorder); } Is there an adjustment I can make to this that will give me a different order each time? I realize this is a hack to the plugin but I need to do it. I'm waiting on the plugin developer to formally add it as an option in the admin area of the plugin. Don't know when he'll get to it :-) Thanks!
-
Hah! That was easy Thanks!
-
I just did this myself with the help of the fine folks here. First, eBay supplies time left as TimeLeft in their getsingleitem call. But it is indeed in the standardized format. This reformats it: $timeLeft = $res->Item->TimeLeft; $x =array(1 => 'Day', 'Hour', 'Minute', 'Second'); //escaped backslashes are for the Wordpress quicktag which removes backslashes upon insert. preg_match('/\\AP(?\\d*)D)?T(?\\d*)H)?(?\\d*)M)?(\\d*)S\\z/x',$timeLeft, $d); for ($i = 1; $i < 5; $i++){ $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; } BTW I'm using the PHP kit from eBay which has a complete package of the API wrapped in PHP. Example in use here: www.smallartgems.com
-
Hi, I have a piece of data supplied as a dollar amount: Example: $1.95 However, if the dollar amount happens to end in zero, then is is supplied without the zero. Example: $1.9 So, I need to test for the second digit after the decimal and if it isn't there, add a zero. How can I do that? Maybe regexp is applicable here?? Any help would be greatly appreciated. Thanks!
-
Hi, I've got a function that is part of a code snippet I insert into blog posts in WordPress. Trouble is I may insert the snippet several times in the same post. PHP throws an error of course since the function was already declared in the previous insertion of the snippet. I would add the function to the centralized functions include file in WordPress but every time I upgrade WordPress it is overwritten. I'm not likely to remember that I've got function(s) in that file that I need six months from now if I upgrade ;-) So, can I wrap the function in some sort of "if this function is declared then ignore this" thing? If so, what's the test for whether it has been declared? Thanks!
-
Disregard. Found this function: function reformat_date($date, $format){ // Function written by Marcus L. Griswold (vujsa) // Can be found at http://www.handyphp.com // Do not remove this header! $output = date($format, strtotime($date)); return $output; } And it works like a charm. Can be found here: http://www.handyphp.com/content/view/10/16/ Hope this helps someone
-
From what I can tell, and I'm no expert, date() formats a time taken from the server. I need to reformat a string that is in one date format to another. Thanks though Any other assistance would be appreciated.
-
Hi, I have a date and time supplied in this format: 2008-03-21 22:58:46 (the time is supplied as GMT) I want to display it in this format: March 21, 2008 at 3:58pm PDT (note Pacific Daylight Time) Any help would be greatly appreciated!
-
Geeez! I wish I knew this stuff. I simply don't use it enough to warrant the education. I'm an artist getting my own site online so painting is what I do. I used to develop sites but never got into regexp or much scripting. The sites I built were pretty simple. All in WordPress. Thanks so much for your help on this. I can't imagine how folk like me would get along without your help and those like you. You are all much appreciated!
-
HeHe...THAT is meant to replace the whole snippet, yes? Thanks a million for your input on this Since what I have now is this: $timeLeft = $res->Item->TimeLeft; $x =array(1 => 'Day', 'Hour', 'Minute'); //if using as quicktag in wordpress you must escape the backslashes because the quicktag insertion removes them. preg_match('/\\AP(\\d*)T(?\\d*)H)?(?\\d*)M)?(\\d*)S\\z/x',$timeLeft, $d); //preg_match('/\AP(\d*)T(?\d*)H)?(?\d*)M)?(\d*)S\z/x',$timeLeft, $d); //original code for ($i = 1; $i < 4; $i++){ $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; } Could it not be tweaked to add the display of seconds? Is there something about this code that is faulty?
-
Thanks! Actually my definition of snippet was the entire piece of code I figured you meant the regex string though so I tried it and of course it worked Thanks Much! One other tiny thing...the php part omits the display of seconds once minutes are zero. What do I need to make seconds display as well?
-
Thanks effigy! Please pardon my regex ignorance but is that meant to replace the entire snippet?
-
Hi, Many thanks to member sasa who provided me with the code below last night under a previous topic. I thought it was all buttoned up until I noticed this morning how eBay was providing the data. The code formats a response I receive from the eBay API. The data represents the time left in an auction and is typically supplied as: P2T9H37M8S Broken down, that is: P(period)=2days T=9Hours37Minutes8Seconds I thought all was well with the code except I've discovered that eBay supplies the data a bit differently than I thought as the time winds down. Thus the code breaks. It seems when the hours reach zero, eBay then supplies the data like this: PT37M8S And when Minutes reaches zero, like this: PT8S Sooooo... How can the code be modified to accommodate this? $timeLeft = $res->Item->TimeLeft; $x =array(1 => 'Day', 'Hour', 'Minute'); preg_match('/P(\d*)T(\d*)H(\d*)M/',$timeLeft, $d); for ($i = 1; $i < 4; $i++){ $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; } Any help would be greatly appreciated!
-
Update, Got the div formatting and styling to work. Wrapped $dare in it. echo '<div style="text-align:center;clear:both;background:#cccccc;padding:2px;"><em>Time Left: </em>' . $dare . ' '; Works like a charm! Many, many thanks to all who assisted. I got a good education on this one
-
Thanks Daniel0! Clear on that now.
-
Thanks sasa, The only thing I'm confused about is where to enclose the output in a div. Should I concatenate it in this string? $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; If so, how? It does print properly BTW but I just need format it. Once I understand the concatenation I'll be fine. Thanks!
-
Thanks sasa for the explanation of the mechanism. Much appreciated!
-
Thanks Daniel0! Please pardon my ignorance, but why is he doing that? Why not $dare= ? Thanks! BTW, I'm an artist so it's a miracle I can even remotely understand regex, but I'm getting there...slowly htp://www.smallartgems.com/collectors-gallery
-
sasa, Regarding this line: $dare .= $d[$i] ? $d[$i].' '.$x[$i].($d[$i] > 1 ? 's ' : ' ') :''; I need to add divs and styles etc. One question: What is the significance of the *.* in *$dare .=* ? Thanks!
-
Thanks sasa! That seems to work well. Now I have to add in styling which I think I can do. I'll add to this post if I run into problems with that. You used regex correct? I haven't a clue how it works but would like to at least know the mechanism you're using. Can you post a brief explanation? Thanks again to you and to charlieholder