By Mr Maggoo on
Hi, I wrote this little module that displays random quotes in a block:
function random_quote_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Random Quotes Block');
return $blocks;
}
else if (user_access('access content')) {
$quotes_array = file('quotes.txt');
$quote = $quotes_array[rand(0, count($quotes_array) - 1)];
$quote = trim($quote);
$content = "<b><i>We tried to imagine our ideal boatyard...</i></b><br /><br />";
$content .= "<i>"".$quote.""</i>";
$block['subject'] = t('');
$block['content'] = $content;
return $block;
}
}
Everything went well, until I did an upgrade, whereupon all the single quotes (') in the quotes turned into question marks.
the quotes file looks like this:
We wanted a proper working boatyard with boatyard smells and activity where owners can come and go and do as much or as little on their boats as they wanted to; where there was professional advice and service on hand and expertise when it’s needed.
We wanted a quiet and peaceful location because we were going to spend a lot of time there and it was going to be holiday, care-free time to dream a little as well as to work and scrub and paint.
We wanted to feel that the yard would know us and know our boat and want to look after it and know how we wanted it to be kept and that it was safe when we left it.
We wanted to be able to relax after a day’s work and wash and shower and not have to lug our outboard home and where we could get a drink or a snack for the journey.
We wanted to know that we could get any job done without having to traipse into town and to know that it would be done and done well and not interrupt our sailing plans.
We wanted to admire craftsmanship and expertise where we don’t possess it and to recognise skill and to find a special job done better than we had imagined it.
We wanted to know that we could ring up at any time to ask for help and we want to go on board on any day of the year without needing a pass or a key.
We wanted to know that there would be other people around doing much the same as we are and that we could chat to them but we didn’t have to; we also wanted to sit on our mooring as just us.
We wanted to know that our boat would be handled with care, that there was sensible equipment to move it and that the people knew what they were doing.
We wanted to go there and we wanted to come back after a passage; we wanted more and more and more…..
As you can see, no question marks.
The PHP code works a treat when not in the Drupal block system.
Do you have any ideas as wo why this might occur?
Thanks
Miles
Comments
P.S.
Oh yeah,
you can see an example of what is happening at
http://www.weir-quay.com/
Keep refreshing the page until you find a quote that has a single quote in it.
Thanks again
Miles
That's not a single quote
It's a tick (also called a tail).
Single quote: '
Tick: ’
That's why.
Dur...
Do you ever feel like hitting your forehead repeatedly on a desk?
I do.
Frequently.
Thanks very much!
Miles
Quotes Module
Did you know that there is a quotes module in existance?
http://drupal.org/project/quotes
--
Drupal development and customization: 2bits.com
Personal: Baheyeldin.com
--
Drupal performance tuning and optimization, hosting, development, and consulting: 2bits.com, Inc. and Twitter at: @2bits
Personal blog: Ba