A couple of us have wondered about how you "Allow tokens in advanced mode". User soulfroys discovered that the Convert option does this.

However, Convert is not obviously available on-screen, unless you create a sample BASIC formatter, and even then, there is no explanation of what it does.

How about adding a comment on the Advanced screen, that if you want to include tokens in PHP code, then you simply create a BASIC formatter first, and from the List summary option, chose the Convert operator to convert the BASIC formatter into an Advanced PHP formatter.

Comments

Deciphered’s picture

Status: Active » Closed (won't fix)

If you want to use Tokens in Advanced formatters you should be invoking the token_replace function manually, Convert is only a quick extra I threw in after I made the functionality available for the use of the Export feature.

I wouldn't recommend using Tokens in Advanced mode at all, instead just use the values of the data provided, as that's all the Tokens are going to do anyway.

I'm marking this as won't fix, but I may reconsider it as a documentation issue (to the Help module integration, not on the Advanced formatter screen as suggested) if there is enough support for it or if there is a patch submitted.

Cheers,
Deciphered.

iantresman’s picture

My problem is that I have no idea how to "use the values of the data provided". I can understand tokens, but it is not intuitive how to convert this into the required PHP to access the data provided.

Just as Basic mode has an option to view tokens, it would be incredibly useful if Advance mode had an option to display a table of tokens and their corresponding PHP equivalents.

Deciphered’s picture

iantresman,

I do understand where you're coming from, but the advanced mode is for raw PHP coding, and all the possible hand holding for this mode has been done (at least in D7) and that doesn't and never will contain Token support.

If you hell bent on using the advanced mode then I would urge you to push yourself to not use Tokens and learn the alternative approach as it will better your skills in the long run. If you are hell bent on using Tokens, review the code of the modules that define the Tokens, because when they define it you will be able to see how they are manipulating the provided data and you can then do the same without the use of the Tokens.

I know this isn't exactly a helpful response, but there is no question about it that the advanced mode is meant to be advanced. Maybe in D7 I might consider adding a third mode which is a combination of the PHP and the HTML+Tokens mode, but I can't see that being backported to D6 unless it's on behalf of a client.

Cheers,
Deciphered.

iantresman’s picture

I am quite happy to not use tokens. And I understand that "Advanced" is just that. But Advanced mode can be made much easier by a little hand-holding. For example:

  1. The Content Templates (Contemplate) module has an excellent option, to display all the available variables for its templates. Just enable the module and go to Admin | Content Templates. Then select Edit template for a content type (eg. page), and expand one of the sections, say, Body.

    The useful part is the help section "Body Variables". I can instantly see how to use data from any of my fields. I would guess this is similar to what devel produces, but without having to install it!

  2. It would also be useful to know what the examples provided, actually did, and provide some more Advanced ones that did some fairly simply things. Perhaps some more examples could be provided in /help (which I've only just found in 1.6, and didn't seem to be present in v1.5)
Deciphered’s picture

Title: Custom Formatters: Mention "Convert" on-screen » Advanced usability discussion.
Category: feature » task
Status: Closed (won't fix) » Active

iantresman,

With Devel and Devel generate enabled a preview mode is enabled that will allow you to preview the formatter while creating it. This is definitely vastly improved in the Drupal 7 version, but I currently have no plans to backport 2.0 to Drupal 6.

Given the nature of the type of data being passed through, I can't see it being a simple case of showing the available variables, however the preview feature in D7 is quite close. I have looked into this before, but I may look at it again the future as I never specifically peered at contemplates code.

More examples would be great, and I am trying to push out a site for sharing Formatter snippets which will also house a blog that could cover that sort of thing. I would be happy to proof read a tutorial and commit it in some form if it where provided.

I've re-opened this, renamed and re-categorized as I'm more than happy to keep the discussion going, usability is important, this module probably isn't as easy as it could be.

Cheers,
Deciphered.

iantresman’s picture

Many thanks for your consideration. Hope you have a chance to look at the Contemplate option I mentioned to see whether it is worth considering.

Much appreciated and thanks again.

Deciphered’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

I am no longer supporting any Drupal 6 modules, as such I am marking this as closed.

However, I am open to taking on co-maintainers, if you wish to do so contact me via me D.o contact form.