2
votes

I'm new to Drupal and am trying to embed a Flash game in the middle of the front page. I've created a "Full HTML" text format in Home >> Administration >> Configuration >> Content authoring and I've created a new block using that format by going into Home >> Administration >> Structure >> Blocks and placed it into Content region and display it at the <front> page only:

enter image description here

My problem is that I need to pass the user id and also a custom gender field to the swf file through the FlashVars parameter.

I can see my gender field in the database (I use PostgreSQL 8.4.7/CentOS 5.5/PHP 5.3):

# select * from field_data_field_gender;
 entity_type | bundle | deleted | entity_id | revision_id | language | delta | field_gender_value
-------------+--------+---------+-----------+-------------+----------+-------+--------------------
 user        | user   |       0 |         6 |           6 | und      |     0 | Male
 user        | user   |       0 |         5 |           5 | und      |     0 | Male
 user        | user   |       0 |         1 |           1 | und      |     0 | Male
 user        | user   |       0 |         7 |           7 | und      |     0 | Female

And I see the users table:

# select uid, name from users;
 uid | name
-----+-------
   5 | Vasja
   6 | Vanja
   1 | Alex
   0 |
   7 | Petja

But how could I print them into my custom content block?

I also suppose there is already some prefilled data structure there, something like a $user array?

Please give me a bit help and directions to get me running on custom blocks.

I'm looking at the docs, but they're talking about custom modules, which is probably a bit overkill in my case?

And also I need to print a message to the Anonymous user telling him or her to sign in or register. Please give me a pointer here

Thank you! Alex

P.S. My understanding is that swfobject isn't working well with Drupal 7 yet, but that is not a big issue for me.

1

1 Answers

1
votes

It sounds like you want to be able to execute PHP code in your block's content. The Full HTML filter mode is not sufficient for that. Take a look at the PHP Filter module. It's included in core, but needs to be activated first, before you can use it for your block.

After that you can use normal PHP code, at which point the documentation on custom modules applies. You could for example access the $user array to retrieve fields, or make direct db calls, depending on where your required information is.

Edit: Of course, having full PHP access is powerful and should only be allowed for administrators. Hence, make a new specific content type in which you allow the PHP filter and ensure in the permissions that no user other than an administrator can create or edit that content type.