Title problems in new block

Title problems in new block

par Annie Price,
Nombre de réponses : 6

Hi All,

Using the documentation at http://moodle.org/blocks/HOWTO.html I have successfully created a new block for my customer support button.

The title of the block is 'Support', however, my title appears as support

See http://www.worldwidemediums.net to see what I mean

What have I done that the brackets appear in the title and how can I remove them?

Any help would be appreciated

Annie

Moyenne des évaluations  -
En réponse à Annie Price

Re: Title problems in new block

par Justin Filip,
In your init() method, you would have a line like this:

$this->title = get_string('support');

The get_string() tries to find the string you gave it within /lang/*/moodle.php (unless you give it a specific filename to search).  The square brackets mean that the string 'support' doesn't exist in the file you're searching.  To keep the changes local, create a language file within your block directory, something like:

/blocks/BLOCKNAME/lang/en/block_BLOCKNAME.php

Where BLOCKNAME is the name of your block.  And in that file you can put lines like:

$string['support'] = 'Support';

You would then want to change your init method to instead look like this:

$this->title = get_string('support', 'block_BLOCKNAME.php');

This would tell get_string() to look for $string['support'] within the language file you've created.  You can do this for any strings that your block will display and it allows people to easily change your block to use different languages just by making a new language file for their language.
En réponse à Justin Filip

Re: Title problems in new block

par Chris Lamb,

As an alternative, if you were prepared to hard-code your block's title rather than have the text in a language file, just replace the line which currently says

    $this->title = get_string('simplehtml', 'block_simplehtml');

with one which says

    $this->title = 'My Block Title';

Hope this helps

Chris

En réponse à Chris Lamb

Re: Title problems in new block

par Annie Price,

Hiya

Thank you both for the help - I have gone for the hard coding option as it was simplest

Annie

En réponse à Annie Price

Re: Title problems in new block

par bill hamilton,

I have two questions for you, Annie:

First, you say the hard coding option was simplest; if you choose hard coding, don't you have to write the php or whatever (I don't have a clue how you hard code anything) on any other blocks you may need to change?

and, second, Your banner and blocks look great!  How complicated is it to change the look of the blocks and the main banner on your page?  I've been wanting to do that for a while, but I haven't a clue how to do it.

thanks,

bill