Jump to content

pealo86

Members
  • Posts

    60
  • Joined

  • Last visited

Everything posted by pealo86

  1. I'm using the following script on my website, it used to work fine but now it just outputs 'error' from the else statement: <?php $username = 'pealo86'; $scrobbler_url = "http://ws.audioscrobbler.com/2.0/user/" . $username . "/recenttracks"; $scrobbler_cache_file = 'scrobbler_' . $username . '_data.cache'; if (file_exists($scrobbler_cache_file)) { if (time() - filemtime($scrobbler_cache_file) > 180) { // if the file was created more than 3 minutes ago then delete. unlink($scrobbler_cache_file); } else { $scrobbler_url = realpath('./' . $scrobbler_cache_file); } } if ($scrobbler_xml = file_get_contents($scrobbler_url)) { $scrobbler_data = simplexml_load_string($scrobbler_xml); if (!file_exists($scrobbler_cache_file)) { file_put_contents($scrobbler_cache_file, $scrobbler_xml); } // limit to 3 songs $count = 0; echo '<ul id="feed-lastfm">'; foreach ($scrobbler_data->track as $track) { if ($count == 3) { break; } else { $string = '<li>'; $string .= '<div class="cover">'; if ($track->image[1] != '') { $string .= '<a href="' . $track->url . '"><img src="' . $track->image[1] . '" alt="' . $track->album . '" /></a>'; } $string .= '</div>'; $string .= '<div class="content">'; $string .= '<span class="title"><a href="' . $track->url . '"><strong>' . $track->artist . '</strong>: ' . $track->name . '</a></span>'; if (!$track->date) { $date = '<span class="highlight-00a2f5 currently-listening">Currently Listening</span>'; } else { $date = 'Played: ' .$track->date; } $string .= '<span class="date">' . $date . '</span>'; $string .= '</div>'; $string .= '</li>'; echo $string; $count ++; } } echo '</ul>'; } else { echo 'error'; } ?> I got the script from here: - http://www.hashbangcode.com/blog/simple-php-code-get-lastfm-last-played-tracks-605.html Does anyone have any idea what I'm missing?
  2. I am positioning an anchor like so: #test-link { position: relative; bottom: 100px } As I need it so that when I visit #test-link the page jumps down to that particular section, but 100px higher. Otherwise the page scrolls too far down for what I need. This works fine in decent browsers, however in IE7, 8 and 9 the relative positioning gets completely ignored. I've tried different ways to fix it such as adding text to the anchor as well as various CSS properties (e.g. display: block) however nothing makes any difference. Does anyone have any ideas?
  3. Ahhh yes! I didn't think it would be needed in my WP loop, but obviously it is! Thanks again.
  4. Thank you! The script appears to work fine on it's own, however in my WordPress loop it behaves the same as the previous solution. In that it gives me I have no idea why this is! My WordPress loop is like so: <?php query_posts('post_type=team-member&posts_per_page=-1&orderby=menu_order&order=ASC'); ?> <?php if(have_posts()) : ?> <?php $count = 1; ?> <div id="feed" class="feed"> <?php while(have_posts()) : the_post(); ?> <?php // determine alpha / omega class if (($count - 1) % 4 == 0) { $grid = 'alpha'; } elseif ($count % 4 == 0) { $grid = 'omega'; } echo '<br class="clear" />'; echo '<p>' . $count . ' ' . $grid . '</p>'; echo '<br class="clear" />'; ?> <?php $count ++; ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_query(); ?> I'm not sure how familiar with WordPress anyone here is, but can you think of any reason why it might be doing this? :/
  5. Ahhh no, what I'd like is something like the following: If you could let me know how to acheive this with the modulus operator that would be great
  6. Hmmm okay this is confusing, I've simplified my WordPress loop like so: <?php query_posts('post_type=team-member&posts_per_page=-1&orderby=title&order=ASC'); ?> <?php if(have_posts()) : ?> <?php $count = 1; ?> <div id="feed-the-team" class="feed"> <?php while(have_posts()) : the_post(); ?> <?php // determine alpha / omega class if ($count % 4 == 1) { $grid = 'alpha'; } elseif ($count % 4 == 0) { $grid = 'omega'; } ?> <h2><?php echo $grid; ?></h2> <?php $count ++; ?> <?php endwhile; ?> </div> <?php endif; ?> <?php wp_reset_query(); ?> Yet it's outputting the following: Am I missing something really obvious here?
  7. Just tested in a basic PHP file and it seems to work! There must be something in my WP loop that I haven't spotted so I'll look into it further. Thanks again!
  8. Thanks! That's what I mean yes, however those snippets of code seem to return true on iterations 1, 2 and 3 instead of just 1. I should probably point out, $count starts off at 1 as opposed to 0. But I can't seem to get it to work either way?
  9. Thanks, but that's not what I meant exactly. I suppose a better way of putting it is to say every 4th iteration, but starting from the first if that makes sense?
  10. I can use the modulus operator to target a specific iteration of a loop... other than the first! As dividing by '1' will obviously never give a remainder. Here is the code I'm using: <?php // determine alpha / omega class if ($count % 1 == 0) { // do this } elseif ($count % 4 == 0) { // do that } ?> Can anyone see another way around it?
  11. Oops, managed to fix it in the end. Turns out it's more common than I thought: http://stackoverflow.com/questions/6111823/disable-horizontal-scrollbar-due-to-a-div-with-positionabsolute-which-is-outsid Adding left:-100px is fine but browsers don't seem to like it on the right!? Thanks anyway though!
  12. On the following page: http://www.mattpealing-server.co.uk/~devcurti/ I'm positioning #banner-disc like so: #banner-disc { background: url("../image/banner-disc.gif") repeat scroll 0 0 transparent; clear: both; display: block; height: 270px; margin-right: -100px; position: absolute; right: 0; top: 0; width: 846px; z-index: 0; } However it's causing a horizontal scrollbar at a 1024px wide display. I've tried other ways of positioning the element, even using relative positioning. However I just can't seem to get rid of the scrollbar. Can anyone else see what I'm doing wrong?
  13. I'm using the following code as I don't want people to view singular custom posts. If they try to visit one, I want them to get forwarded to a page: <?php // forward necessary single custom posts $forward = 0; if(is_singular('external-link')) { $location = get_permalink(12); $forward = 1; } if ($forward == 1) { header('Location: ' . $location); } exit; ?> However even with error reporting turned on I just get a blank white screen. I normally use the following script on most websites I make: <?php // forward necessary single custom posts if(is_singular('external-link')) { $location = get_permalink(12); $forward = 1; } if ($forward) { header('Location: ' . $location); } exit; ?> However on this site it is just giving me this error: Notice: Undefined variable: forward in /home/devspare/public_html/wp-content/themes/sparetimetocash/header.php on line 8 Can anyone see any issues?? It seems like if I resolve the error messages all I get is a white screen of death
  14. I've set up a form in the sidebar of: - http://www.mattpealing-server.co.uk/~devashwo/ When the form is submitted, the results are supposed to be displayed in the iframe on this page: - http://www.mattpealing-server.co.uk/~devashwo/search/ However as you can see, if you submit the form from the homepage, the page strangely opens up in a new tab (and the form data isn't posted properly to the iframe resulting in an error message). Also, if you try to submit the form from the search page itself, sometimes the page you are browsing then opens up in the iframe. (see attached image). This doesn't appear to happen all the time however, it seems to be an intermittent problem. I've set my form up like so: <form action="<?php echo get_permalink(17); ?>" method="post" target="vebra"> and my iframe: <iframe id="vebra" name="vebra" src="http://www.vebra.com/home/quick/PFresults.asp"></iframe> But cannot see anything wrong with the code that would cause bizarre errors such as this?
  15. I'm trying firstly to output hidden fields based on the values of the $_POST variable. Then after that I want to output the values again in a unordered list. I'm using the following code: while (list($key, $val) = each($_POST)) { if ($key != 'Submit') { echo '<input type="hidden" name="' . $key . '" value="' . $val . '" />'; } } echo '<ul>'; while (list($key, $val) = each($_POST)) { if ($key != 'Submit') { echo '<li><strong>' . $key . '</strong>: <span class="highlight-219ddb">' . $val . '</span></li>'; } } echo '</ul>'; However the <ul> appears to be blank? Can I only use the list() function once on a particular variable?
  16. Wow I have no idea how that +1 got in there! The operator I was actually using was like this: <?php if ($count % 3) : ?> Which I assume is still incorrect. I've updated it now to <?php if (($count) % 3 == 2) : ?> And it's working fine. I see what you mean about the variables, however the number of loop iterations is actually taken care of by WordPress in my real-life situation, but I'll definiately keep it in mind. Thanks for the help!
  17. To solve a bigger issue I'm having in WordPress, I have thrown together this basic script in PHP script to help me get to the bottom of it. Basically, I am trying to add a <hr /> tag after every 3rd paragraph: http://www.mattpealing-server.co.uk/~freshmat/wp-content/themes/match2move/test.php With the following code: <?php $count = 0; ?> <?php while($count < 20) : ?> <span> <p><strong><?php echo $count; ?>:</strong> Lorem ipsum dolor sit amet, consectetuer adipiscing.</p> </span> <?php if ($count % 3) : ?><hr /><?php endif; ?> <?php $count ++; ?> <?php endwhile; ?> However if you notice, this output just doesn't turn out like this! Does the operator I'm using not test if $count is a multiple of 3?
  18. This problem is a little more complex than I thought. I'm trying (in Wordpress) to output 3 <span> elements in each iteration of the loop. However each <span> element needs to advance the loop to the next iteration (if that makes sense). See here: <?php $count = 0; ?> <?php if(have_posts()) : ?> <?php while(have_posts()) : the_post(); ?> <div class="divide"> <span> <a href="<?php the_permalink(); ?>"> <span class="icon-home"><img src="<?php bloginfo('template_url'); ?>/image/icon-home-01.png" alt="Property" /></span> <span class="content"><?php the_title(); ?></span> </a> </span> </div> <?php $count ++; ?> <?php endwhile; ?> <?php endif; ?> There needs to be 3 <span> elements inside each <div class="divide" /> element. One thing I did try was to include a for loop inside 'div.divide' so that it output 3 of the <span> elements. But then I realised it simply output 3 of the same elements (e.g. all of the 'the_title()' fields were the same instead of advancing onto the next post). Does anyone have an idea how I can achieve it? Hopefully that makes sense, but I'm having trouble explaining it! MOD EDIT: . . . tags fixed . . .
  19. I am using http://css3pie.com to add CSS3 features (just border-radius and background gradients) to this site I'm building: http://concept.freshbeat.co.uk/match2move-27102011-02/0-dev/ However, the gradient backgrounds do not appear to be working in IE9. According to the CSS3 PIE website, the latest version adds support for IE9 gradients. It's strange how it works in IE 6, 7 and 8 but not in IE9. Has anyone else had this problem? For example, I am styling the pink navigation bar like so: #nav { behavior: url(./script/PIE-1.0beta5/PIE.htc); background: #fa3b90; /* Old browsers */ background: -moz-linear-gradient(top, #fa3b90 0%, #c80468 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#fa3b90), color-stop(100%,#c80468)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #fa3b90 0%,#c80468 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #fa3b90 0%,#c80468 100%); /* Opera 11.10+ */ background: -ms-linear-gradient(top, #fa3b90 0%,#c80468 100%); /* IE10+ */ background: linear-gradient(top, #fa3b90 0%,#c80468 100%); /* W3C */ -pie-background: linear-gradient(top, #fa3b90 0%,#c80468 100%); /* PIE */ margin: 10px; border-radius: 10px; -moz-border-radius: 10px; float: left; width: 928px; padding-left: 10px; margin-bottom: 10px; border: #fa3b90 solid 1px; }
  20. Oops sorry! Here they are again: First http://concept.freshbeat.co.uk/jobsworkingfromhomedirectory-16102011/0-dev/test/ Second: http://concept.freshbeat.co.uk/jobsworkingfromhomedirectory-16102011/0-dev/ Thanks
  21. I've made a basic interactive CSS / jQuery map of the UK in which each country is highlight as you hover over it. Here is a link to it: http://concept.freshbeat.co.uk/jobsworkingfromhomedirectory-14102011/0-dev/test/ I have highlighted each country with a red border so that you can see the dimensions of each image. Of course, it works fine in all browsers bar IE, although I'm a little surprised to see that it doesn't even work in IE9. It seems as though IE just isn't reading the z-index properties properly. It's like you have to hover completely out of the map and then carefully hover over your country of choice, without touching any of the others. One thing I've just stumbled across whilst testing it, I decided to add a background colour to each <a> so that I could see if they were stacked in the correct order in IE. And now I've found that the hover's work perfectly in IE when a background colour is applied?! See here: http://concept.freshbeat.co.uk/jobsworkingfromhomedirectory-14102011/0-dev/ Even in IE7, the map works fine when background colours are applied. The problem might be due to the fact that I'm using transparent .png's? Does anyone know of a workaround? As me slicing up the map and applying a separate background to each individual <a> tag isn't an idea solution, although it may be the only one!
  22. I managed to get around it with this in the end though, quite handy http://www.cssstickyfooter.com/
  23. Also, I've set html, body { height: 100%; } However the body only extends to the fold, not the page as such. See the attached image, I've made the body green and the html red. This is when testing at 1280 x 768, it appears fine at lager resolutions. Does anyone have any ideas? [attachment deleted by admin]
  24. I have the following page: http://www.mattpealing.co.uk/concept/chm/ ...and am trying to position the footer so that it is always at the bottom of the page with: #footer { overflow: hidden; position: absolute; bottom: 0; left: 0; width: 100%; padding: 10px 0; background: #db921a; } However it only seems to be aligning with the bottom of the page, not the browser as such (see attached image). Does anyone know what I might be missing? [attachment deleted by admin]
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.