Why no token is for file URL?

I would like to make formatter for HTML5 display of video files. It could be as simple as:

<video src="url_to_myvideo.ogv" preload controls></video>

or in more elaborated form:

<video id="myid" width="320" height="240" preload controls>
  <source src="url_to_myvideo.ogv" type='video/ogg; codecs="theora, vorbis"' />
</video>

I am not developer, and writing PHP formatter is too difficult for me.

Please help

Comments

AndrzejG’s picture

I tried to write advanced formatter using http://drupal.org/node/753428 as the example, but make syntax errors.

deciphered’s picture

Status: Active » Fixed

AndrzejG,

I'd recommend that you use the HTML + Tokens engine, but to do so you will need to have the Token module installed and patched with the patch from http://drupal.org/node/691078#comment-4594082

If that is too difficult, I would suggest contacting a developer to port the code from the reference issue so it works with Custom Formatters D7, or waiting until the long awaited Token module fixes are made.

Cheers,
Deciphered.

AndrzejG’s picture

Thank You, Stuart.

Is it enough to upload this patch to the root of sites/modules/token?

deciphered’s picture

http://drupal.org/node/707484 <- read that (specifically the section on Applying a patch)

AndrzejG’s picture

I have read this some times, the problem is that I run my site on hosted server with FTP only.
Of course I can type in manually the patches as most of them are additions.

deciphered’s picture

If it's at all possible, try setting up a local environment then uploading your patched code. I had to go through the Tokens patch by hand last night as it was no longer applying correctly, hence the new patch I built, and going through manually was quite an arduous task.

AndrzejG’s picture

Status: Fixed » Closed (fixed)

I can imagine. Sometimes I make localizations for rather big applications, and .po files are so long...

Thank You, Stuart, for Your kind help. I keep this ticket closed as in fact it should be addressed to the Token module team.

I won't return to my old comp with old Ubuntu, but will set my light and efficient text editor to UTF-8 and it will facilitate the work.

BTW I think introducing the abstraction of Entities was quite good choice to make Drupal more flexible. However, I wonder why the Files are not considered as a category of Entities, same as users, taxonomy terms, nodes etc. From my semantic works I know, that this omission will cause a lot of so called "identifier problems" and consequently the problems with tokens.

Best regards

AndrzejG’s picture

Ough, by inattention banned from Freenode ;(

deciphered’s picture

Status: Closed (fixed) » Active

I'm sure that the ban will be lifted in time.

In general if you have large amounts of code/text to share you use an issue queue or a codebin.

Post the details of your issue here and I'll take a look at it as soon as I can. Include the errors your receiving, the code/settings you're using in your formatter, maybe even a screenshot of both, and any other information that you think may be of interest, like versions of modules directly involved.

Cheers,
Deciphered.

AndrzejG’s picture

OK, I manage to bypass the error through Views and it works OK.
I also wrote to Freenode to unban me ;(

I am enormously tired, so I will send You details tomorrow (here in Poland is 4:18 am now).

Thank You once more for Your great help.

AndrzejG’s picture

Thanks to great help of Deciphered I could use His patch to the token module (see http://drupal.org/node/691078), and below I report what I found. Probably I should write this to that referenced topic, but I don't want to disturb the waiting/pressure for token module maintainers.

The formatter with [node:field-ogv:file:url] works fine: the preview in Custom Formatters interface is displayed well. The field formatted using this token is also displayed well except of the warning:

User warning: Attempting to perform token replacement for token type file-field-value without required data w token_tokens() (line 757 from /sites/all/modules/token/token.tokens.inc).

The same warning is displayed 2 times in the test page generated by the Views when using this formatter. After second hit it is displayed once.

-----
For the completeness let me report that I started my test using more general token, [node:field-ogv]. When not enabled in the fields display of my testing Content type, the token displayed video OK in the Custom Formatter preview. When enabled, instead of page display I got the error:

Fatal error: Maximum execution depth reached (1000) in /includes/bootstrap.inc on line 155

Fatal error: Maximum execution depth reached (1000) in Unknown on line 0 (three times);

and in Custom Formatter preview I got the error:

Wystąpił błąd w AJAX HTTP. (i. e. Error occurs in AJAX HTTP.)
Błąd HTTP: 200
Informacje diagnostyczne
Ścieżka: /system/ajax (i. e. path)
StatusText: OK
ResponseText:
Fatal error: Maximum execution depth reached (1000) in /includes/common.inc on line 300
Fatal error: Maximum execution depth reached (1000) in Unknown on line 0 (also 3 times).

deciphered’s picture

Hi AndrzejG,

The first issue you refer to is or should be fixed in 7.x-2.0-beta3, update and give that a whirl.

The second issue you refer to is most likely a bug with Tokens, with the particular token you used. I'll try to test that to confirm.

Cheers,
Deciphered.

AndrzejG’s picture

I had beta3 when doing these last tests. Today I checked carefully, and also made update according to the advice http://drupal.org/node/1185596. Unfortunately, the first error didn't disappear.

BTW I noticed also a lot of inconsistencies in contributed Views modules. I had to disable field_injector_formatter due to some conflicts, fortunately useless for me. Now after update to the fresh versions of Entity, Pathauto and... have some conflicts with flag_views... discouraged after almost 2 months of fighting.

AndrzejG’s picture

Ah, I missed to add potentially important notice.
During previous test session I had to update FileField Path module, and after taht all Custom Formatters UI disappeared from management UIs. I disabled this FileField Path and Formatters appeared again.

During recent test session the same happened after update Field Injector. I noticed that only /admin/structure/formatters/settings remained visible and accessible.

deciphered’s picture

Status: Active » Closed (duplicate)

Marking as a duplicated of #1184900: Throwing Error When Used.

Fix committed to 7.x-2.x