Hi!

I have created a basic page and within the body text entered the token [site:name] in several places. However, this seems not to be working. Instead of the site's name showing up, the actual token [site:name] appears. Am I doing something wrong? Are tokens allowed here? Maybe there's some other code (e.g., something in HTML) I must use. If so, what is that and what exactly is its syntax?

Thanks,
Richard

Comments

sprite’s picture

Drupal is quite modular, although quite extensible.

Although token support is built into many aspects of Drupal core, tokens are not available by default for use within content body text fields, and Drupal core itself only supports limited set of tokens called "native tokens" and another scope known as the "global tokens". There are other token scopes, which are related to various modules and features, such as: user tokens, content (node) tokens, taxonomy tokens, menu tokens, site tokens, URL tokens, Views tokens, and many, many more.

However, Drupal core includes a feature called text filters.
In order for tokens to function within content body text fields, it is necessary to install a contributed module called "token filter", which is a text filter module that makes tokens (but not every token) available within content body text fields.

Here is a link to the token filter module:

https://www.drupal.org/project/token_filter

Keep in mind that Drupal core is actually relatively small in comparison to the universe of contributed modules that enhance Drupal and that truly make Drupal the powerful tool that it is. Given the nearly unimaginably huge universe of Drupal functionality that one might conceive of, it is highly likely, with some exceptions, that somebody has written a module that implements functionality one needs at any given moment. There may even be more than one similar module that implements desired functionality (for example xmlsitemap versus simple_xmlsitemap). Give yourself a couple years, and if you have an encyclopedic mind, the names of thousands of modules will be at your mental fingertips whenever the need for functionality comes to mind. The scope of Drupal's "essential" modules probably even extends well into the several hundreds, including modules like token filter, which can be at the ready if the need arises while building a website.

Also, the complete master list of tokens available on a Drupal website is always available at:

{site}/admin/help/token

Take notice there are links (with visible arrows on the left), that expand to show the complete lists of tokens for each section/scope of tokens. The available sections of tokens depend on the contributed modules installed and the tokens implemented by those modules. With many modules installed, the list is quite huge, more than can be memorized, and well worth developing familiarity with.

Tokens are a truly powerful Drupal feature that is well worth studying and getting very familiar with.

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

sprite’s picture

Keep in mind that Drupal is way, way, way, more powerful than Drupal beginners imagine.

However, Drupal is also highly modular, and requires installation of modules to access many of its powers.

The foregoing is by design.

It would be really bad design for Drupal core to be any bigger than it is already.

Drupal even has a facility available to address the core versus contrib matter, which is called "distributions" ...

Anybody can put together a Drupal distribution, pre-configured with modules, themes, libraries, and even pre-installed content, even including a custom "install profile", to get Drupal distribution users up and running quickly. Many Drupal distributions exist, but there is always room for more. In addition to free Drupal distributions, there are commercial distributions, in which vendors to the drudgery of assembling many Drupal components together, including theming, content, and even custom application functionality (like CRM, hotel bookings, events management, you name it), and then license the distribution (either free or commercially (often including tech support in the license free (think redhat of Linux fame))).

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

sprite’s picture

Also keep in mind that you should use the "Basic Page" content type only very rarely, if ever at all.

Even as a beginner, you will find that the "Article" content type is much more flexible, and it will display on a page in a manner similar to a basic page, but it can be displayed in lists of "articles" using the Views facility. With Views you can landing pages of lists of Articles nearly "free" by creating a View of content (of content type article), with display mode "Teaser" and you have a landing page with a list of your articles, including truncated versions of the article bodies.

Also keep in mind that you can make your own custom content types. The D8 content types admin GUI even includes a "tools" feature, for copying the fields from one content type to another, so that the fields' configuration is duplicated across multiple content types.

Even if the custom content type structures are similar, using custom content types is an easy way to help organize content, for example with a "news" content type, and a "notes" content type", and a "howto" content type", or an "editorial" content type. Then when creating Views one could then just choose the desired content type and have a pre-limited subset of site content displayed by a View without additional filter criteria.

A more advanced method of organizing content into categories is by using a taxonomy. For example the familiar blogging "tags" feature is an implementation of taxonomy. Or, it is possible to create a "category" taxonomy with Drupal, with the names of site content categories. Then add a taxonomy reference field to the desired content type(s), and use the "filter criteria" option when building a View to limit the categories of content displayed to a subset of the category terms in one's category taxonomy vocabulary.

spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...

rachel_norfolk’s picture

Hi sprite - can you check your email, please? Been trying to get hold of you. Thanks.

richardbmcdonald’s picture

Hi Sprite! I'm replying to your prior three comments here. Your help is outstanding! So, I am installing the Token Filters module; and thanks SO much for that! That should do the trick for me. Indeed, the remarkable depth and vastness of Drupal via the universe of contributed modules is among the reasons I was attracted to Drupal. I expect that, over time, I will become increasingly familiar with the world of all these modules and know how and when to implement them. It really is crazy that for almost every situations "there's an app for that" ; ) The Community is wonderful! And, yes, I am using the content type "basic page" in rare situations like for my site's "About Me", "Terms of Service" and the like pages. The article type is indeed extraordinarily flexable!