GithubHelp home page GithubHelp logo

cascadepublicmedia / calendar_link Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 1.0 14 KB

Drupal 8 module providing Twig functions for creating calendar links.

Home Page: https://www.drupal.org/project/calendar_link

PHP 100.00%
drupal drupal-8 drupal-module drupal-8-module

calendar_link's Introduction

CONTENTS OF THIS FILE

  • Introduction
  • Requirements
  • Installation
  • Configuration
  • Use
  • Examples
  • Maintainers

INTRODUCTION

Calendar links provides two Twig functions for generating links for various calendaring services.

REQUIREMENTS

This module does not require any additional modules outside of Drupal core.

This module uses the spatie/calendar-links library as its foundation. Use composer to install the module (see INSTALLATION) or run composer require spatie/calendar-links separately.

INSTALLATION

CONFIGURATION

There is no configuration available for this module.

USE

This module provides two new Twig functions for generating calendar link URLs:

  1. calendar_link

Returns a string link for a specific calendar type. Available types are:

*. Apple iCal/Microsoft Outlook (ics) *. Google calendar (google) *. Outlook.com (webOutlook) *. Yahoo! calendar (yahoo)

  1. calendar_links

Returns an array of links for all available calendar types. Each array element has the following keys/data:

*. type_key: The calendar type key (ics, google, etc.) *. type_name: The calendar type name ("iCal", "Google", etc.) *. url: The URL for the calendar item.

EXAMPLES

Assume an example "Event" node with the extras fields:

*. Title (string title) *. Start date/time (datetime field_start) *. End date/time (datetime field_end) *. All day event (boolean field_all_day) *. Description (text_format body) *. Location (string field_location)

In a twig template, the following code with generate a link to the event to a Google calendar:

{% set link = calendar_link('google', 
  node.title.value,
  node.field_start.date,
  node.field_end.date,
  node.field_all_day.value,
  node.body.value,
  node.field_location.value
)
%}
<a href="{{ link }}">Add to Google</a>

Or, to create a list of links for each service:

{% set links = calendar_links(
  node.title.value,
  node.field_start.date,
  node.field_end.date,
  node.field_all_day.value,
  node.body.value,
  node.field_location.value
)
%}
<ul>
{% for link in links %}
  <li>
    <a href="{{ link.url }}" 
       class="calendar-link-{{ link.type_key }}">{{ link.type_name }}</a>
  </li>
{% endfor %}

MAINTAINERS

Current maintainers:

Development is sponsored by:

calendar_link's People

Contributors

cdubz avatar

Watchers

 avatar  avatar

Forkers

gaybro8777

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.