Decaflon

Welcome to Decaflon! Where the geeks hang out: Signup or Login Here
Decaflon is proudly hosted by (mt) Media Temple.  We recommend them for your web hosting needs.

ldragon's Activity Stream: Page 1 of 1 « FIRST  ‹ PREV  NEXT ›  LAST »

» Related post plugin?  ...  Last Reply: 7 months ago by ldragon.

Thing about tags is there could be multiple tags per post, so how should the system decided which tag to use to get related posts?

But I've tried to come up with something, keep in mind this with version 2.5+ . Whilst you're in the loop for the single post, put this bit of code in there somewhere:

$tags = get_the_tags();
$related_tag = array_shift($tags);
?>

$related_tag is now an object which contains information on the first tag of the post.

Now what you do is setting up a query_posts function using the tag information wherever you want the related posts to appear. query_posts does act funny sometimes, so this may not work, but I've tested it and it worked on by system. Anyway, you need to put this code in:

$str = 'tag='.$related_tag->name;
$str.= '&showposts=5';
query_posts($str);
while(have_posts()) { the_post();
### loop things in here e.g. the_title(), the_content()
}
?>

The string we send to the function read like this: tag=cooking&showposts=5. So this finds posts matched to that tag and returns the first first.

If you do have multiple tags, you can make the function search for 'posts with any of these tags', but the query you send to the function is slightly different:

$str = 'tag=';
foreach($array as $tag)
{
$str .= $tag->name.',';
}
$str = substr($str,0,-1);
$str.= '&showposts=5';
query_posts($str);
while(have_posts()) { the_post();
### loop things in here
}
?>

This loops through each format and write the query string like this: tag=bread,butter,jam&showposts=5.

In theory this should work. There are other functions to look for posts with, which I tend to use, such as get_posts() and the WP_Query object, but you can search for tags using them.

If you need to put other parameters into the function, this page tells all about the parameters.

Hope that works, and helps :)

» Related post plugin?  ...  Last Reply: 7 months ago by ldragon.

Yeah I think the use of custom fields would be needed, since how are you going to assign a thumbnail to a post? Also, how are the related posts determined, by category, tag etc. I can try and give you a hand if I can get this information.

» Facebook Chat  ...  Last Reply: 7 months ago by RightOn.

Its pretty cool but I tend to open a lot of tabs while on Facebook and im pretty convinced that its crashing my browser :P

Nice article Scrivs, just reading it now

1

Decompressing (p,a,c,k,e,d) Javascript Files

Programming Community — Posted: May. 7, 2008  ...   Last By: Mike @ 8 months ago

Now, I know why most people compress they're js files, because they don't won't people to steal the code, but it must be the case that sometimes, like what happened to me today, you've just gotta crack that encryption. I'm a bit worried about posting this, so I hope it's in someway new and/or useful.

Basically we need to go into a js file that was given to us, in order to change a few DOM-based functions. I opened up the file, and lo and behold, this was the first few characters...

eval(function(p,a,c,k,e,d){...

This is the trademark sign of the packer by Dean Edwards. I'd seen this a few more times, and used it myself too, but never had to decode it before. So I did a little searching and found a nice method of decoding it:

  1. Use the bookmarklet found here whilst on the packer encode/decode page. This will enable the decode button and remove the read-only limitation on the bottom text area.
  2. Paste your encoded code into the bottom textarea and press decode. In theory, you should get the original code, but without line breaks, whitespace etc.
  3. To put the whitespace back in, I used 'Javascript Tidy'. Whilst not 100% successful (depends on your browser it seems somewhat), is did tidy up the majority of the code.

So yeah, that's how to decode the p,a,c,k,e,r compressor. Hope this is useful :)

» What Browser Do You Use?  ...  Last Reply: 8 months ago by dubsar.

At the moment using Firefox for browsing, Opera for feeds and web galleries sites (love that speed dial) and IE for constructive swearing. Yum.

» Calling all PHP Gurus! Complex problem inside!  ...  Last Reply: 8 months ago by ldragon.

Wow thanks for that stuff Oli, never delved into regex much so far, that's helped me a lot. To be fair to this client she is our biggest job in years, so we're pulling out all the stops.

» Calling all PHP Gurus! Complex problem inside!  ...  Last Reply: 8 months ago by ldragon.

The responses I feared :( Ah well, thanks for the input, might try using Regex, event if I can get the values out it will be a GREAT SUCCESS!

Think I might just say to her 'Do it yourself love!'. At least I wasn't alone in thinking the whole idea is bonkers.

» Calling all PHP Gurus! Complex problem inside!  ...  Last Reply: 8 months ago by ldragon.

Don't think I've explained myself very well, the field in question will contain text, be it lists, paragraphs, anything, it's not feesible to say 'special offers prices here' since there will be text accompanying it, and there may not be any prices. It's just if there is, they need to be converted on the fly. Some properties do not have special offers, then this field left blank.

The function needs to go into the text and find any occurences of a price in $ and convert it to £. The rate is defined elsewhere, thats done and dusted.

9

Calling all PHP Gurus! Complex problem inside!

Programming Community — Posted: Apr. 16, 2008  ...   Last By: ldragon @ 8 months ago

There, that got you attention.

I've got a (annoying) client that I'm making a Caribbean property website. She has the functionality to manage the $ to £ and $ to Euro conversion rates, and she only enters the prices in $ in the admin. For the normal pricing section this isn't a problem, since there are individual fields, so conversion is easy.

The problem is the special offers part for each property, since this has to be text so she can be whatever she wants in these fields. But she is insisting on entering the price in $ but wants them to appear in £ on the front-end.

See why she's annoying? I've been looking at the PHP functions such as strpos, strstr, str_replace trying to find a way to automate this.

Basically I'm trying to develop a function that takes a string input and converts all $ prices into £ Sterling. Any ideas would be appreciated, since you're such a helpful lot :)

Here's an example of the type of text in there (I'm moving it all from an older ASP .NET site):

Special Offer:
SPRING SALE

Book before 30 April for travel between 01 March - 31 July 2008.

01-30 April
Standard room £93.00
Deluxe Pool/Gdn View £102.00
Superior Dlxe Pool/Gdn £110.00

1 -31 May
Standard room £85.00
Deluxe Pool/Gdn View £93.00
Superior Dlxe Pool/Gdn £102.00

1 June-31 July
Standard room £80.00
Deluxe Pool/Gdn View £87.00
Superior Dlxe Pool/Gdn £97.00

All prices are per person per night.

» Need help: Mozilla I love, IE drives me crazy...  ...  Last Reply: 8 months ago by ldragon.

Hmm well I can confirm for you definitely does not work on my IE7 either :(

Not very familiar with the and tags, but I think the problem might be on this line:

I don't reckon there's an attribute called blog.littlerockjams :)

Try re-copying the code, because that < bit is code for < right?, maybe it should be more like:

Or maybe that image shouldn't have been there at all, and the classid attribute should match something else/

Hope I've hit on something here :) good luck.

Edit: The code bit of this editor doesnt like me, not showing up the way it should, so view the source at Line 512 here to see what i meant.

4

Custom functions/snippets you could not do without?

Programming Community — Posted: Apr. 11, 2008  ...   Last By: timfletcher @ 8 months ago

I was thinking about this while coding my current project, a property website, and adding a few things to my utility.php file. There are couple of little tidbits/snippets that I've come up with which I could definitely not do without that I've come up with myself (i.e. are not built-in)

I was wondering if anyone else was willing to share theirs, regardless of your programming languange :)

Here's one of my more simple ones ... okay it's not at all impressive, but it saves me a good deal of time when creating/testing a system. It always annoyed me how the php function print_r() was always displayed in a huge inline fashion, and I had to wrap

 tags everytime I wanted to make sense of it, so I made:

function print_p($arr)
{
echo '

';
print_r($arr);
echo '
';
}
?>

Like I said, just a simple example, don't scold me for it's simplicity :)

» dream + teeth = WHAT?  ...  Last Reply: 1 year ago by shadowsun7.

I've been told many times that the whole 'teeth falling out' dream relates to anxiety or nerves. My whole family get this dream when they have big appointments, or in my case rugby matches, the next day.

» On Our Place in this Universe  ...  Last Reply: 1 year ago by ldragon.

Does sound a lot like Freeman doesn't it?

Good on you for sharing this mate, quite a magical video.

2

Firebug equivalent for Safari?

Software Community — Posted: Nov. 4, 2007  ...   Last By: Oli @ 1 year ago

Just wondering if anyone knows if there is any tool for Safari similar to Firebug for Firefox. Specifically the HTML console which updates live when javascript is running etc. Any help would be really appreciated :)

(Ah my bad, wrong community! can someone move this if possible? thanks :P )

ldragon's Activity Stream: Page 1 of 1 « FIRST  ‹ PREV  NEXT ›  LAST »

All Of ldragon's Decaflon Activity:

  • New Notes: 4
  • Comments: 10
  • New Clips: 0
  • Total Clip Votes: 1
  • Positive Clip Votes: 1
  • Negative Clip Votes: 0
 

Decaflon is part of the Chawlk Network of sites.

9 Great Places To Visit, Hang Out, & Meet New People

What's new and interesting at other Chawlk Network sites: