Hướng dẫn Custom Formatters rất dễ cho Drupal Embeds

Hướng dẫn Custom Formatters rất dễ cho Drupal Embeds

Many websites want to allow users to submit videos, audio files, documents and the like.Hướng dẫn Custom Formatters rất dễ cho Drupal Embeds

However, if those files are stored on other sites, it can be difficult to display that content consistently. For example, if you allow people to submit YouTube videos, there are multiple different types of embed code.

One of our members wanted to allow users to submit Google docs that would automatically be shown inside iframes.

The solution to all these problems is the "Custom Formatters" module. Here's how to use Custom Formatters:

The Set-up

We have a content type called Documents. There's a Text field called: Google Doc ID:

media_1398884457297.png

We also have a Google doc. The ID of the Google doc is in the URL:

media_1398884567424.png

Creating a Custom Formatter

media_1398883044081.png

  • Gee the formatter a name and description.
  • Under Format, Choose HTML + Tokens. The other option is PHP.
  • Choose the Field type you want to use. In this example, choose Text.

media_1398883163030.png

media_1398883429749.png
  • Click Tokens.
  • Choose the field that you created earlier:

media_1398883341357.png

  • Replace the specific Google ID in your formatter with the token:

media_1398883393487.png

  • Click Save.

Applying a Custom Formatter

Let's apply the custom formatter to our field:

  • Go to Structure > Content types > Manage Display.
  • Apply your new format to the Google Docs ID field:

media_1398883548283.png

  • Click Save.

Using the Custom Formatter

  • Go to add a new Document to your site.
  • Enter the Google Doc ID as shown:

media_1398883596747.png

  • When you publish the content, the Google Doc ID will be automatically be converted into an iframe embed:

media_1398883618541.png

This technique should work for many other sites such as YouTube, Vimeo or Flickr. You can control the embed and just ask users to enter the unique ID.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Cách chặn tin nhắn quảng cáo phiền phức trên Facebook Messenger

Cách chặn tin nhắn quảng cáo phiền phức trên Facebook Messenger

Dạo gần đây đang rộ lên phong trào spam tin nhắn rác vô tội vạ và hầu như ngày nào mình cũng nhận được ít nhất là 10 tin quảng cáo từ những nick không phải bạn bè

Hướng dẫn xây dựng SaaS business with Drupal

Hướng dẫn xây dựng SaaS business with Drupal

Have you ever thought about building your own Software-as-a-Service (SaaS) business based on Drupal

[Google] Hướng dẫn đăng ký Google AdSense

[Google] Hướng dẫn đăng ký Google AdSense

Google AdSense là một mạng quảng cáo trung gian uy tín của Google dành cho các Publisher và Advertiser, trong bài viết này mình chỉ đề cập tới Publisher, tức là dành cho các chủ website bán quảng cáo trên trang web của mình.

Công ty diệt chuột T&C

 

Diet con trung