By phicarre on
Hello,
I have a question of Drupal's beginner.
I would like to add PHP code into a block. I explain what I did:
1) I enabled admin/build/modules/php filter
2) I created a block
3) I clicked "configure"
4) I wrote the following code (I am using tinymce):
print t('hello');
5) I selected into Input format "php code"
6) I saved
And I see a block with the code inside !!! the code is not executed.
What is missing in my demarch, I suppose that I forgot to initialize something ?
Comments
Have you try to turn off
Have you try to turn off tinymce when using "php code"?
Regards,
Suryanto Rachmat
In tinyMce you must click
In tinyMce you must click SOURCE. Because when you simply write in editor tag '<' or '>' - tinyMce replace it with '& lt;' and '& gt;' , so, when you put the following:
actually you obtain
& lt;php
print 'hi';
?& gt;
I think that the good
I think that the good approach is the first one: turn off TinyMce
If I edit with "html source code" in TinyMce, then my block is empty and If I try to modify my text, then the TinyMce window is empty !
Well, this is normal, that
Well, this is normal, that TinyMce window is empty, because it try to interprept your code. I used in my blocks some not so small parts of code.. Some php code, with using mysql querys, and I have edit it in "source mode". And after that, TinyMCE window was empty. .. One more time. Try to do next steps:
1. open your block
2. edit it with html source code (with PHP code input format). Try, for begin, simple - <?php echo 'Hello, blocks'; ?>
3. Save it
and take a look to result.