Git Product home page Git Product logo

tkiehne-silverstripe-tumblrfeed's Introduction

Tumblr Feed Module

Silverstripe module to load Tumblr feeds via Tumblr API V2

Maintainer Contact

Requirements

  • Silverstripe 3.x

Installation

    $ composer require tkiehne/silverstripe-tumblrfeed

Usage

  • Add to your mysite/_config/config.yml to extend the object of your choice:
    Page:
        extensions:
            - TumblrPageExtension

or set the following call in mysite/_config.php:

    Page::add_extension('TumblrPageExtension');
  • Build and flush using /dev/build/?flush=1
  • Add Tumblr API keys and blog name via Admin > Settings > Tumblr tab (Register your application to get your API keys)
  • Place and Include call in your template (see below for options), e.g.:
    <% include TumblrPosts Posts=$TumblrPostsList %>

Call Methods and Options

All Posts

    TumblrPostsList($limit, $offset, $type, $options)

Proxy Methods for Specific Post Types

    TumblrTextPostsList($limit, $offset, $tag, $text)
    
    TumblrQuotePostsList($limit, $offset, $tag, $text)
    
    TumblrLinkPostsList($limit, $offset, $tag, $text)
    
    TumblrAnswerPostsList($limit, $offset, $tag, $text)
    
    TumblrVideoPostsList($limit, $offset, $tag, $text)
    
    TumblrAudioPostsList($limit, $offset, $tag, $text)
    
    TumblrPhotoPostsList($limit, $offset, $tag, $text)
    
    TumblrChatPostsList($limit, $offset, $tag, $text)

Single Post by ID

    TumblrPost($id, $text)

Options

  • limit = number of posts to show, from 1 to 20 (API max limit)
  • offset = number of posts to skip
  • type = name of post type to retrieve (see below)
  • options = array of API options
  • tag = name of a tag to filter by (single tag only)
  • text = boolean flag; return plain text (true) or html markup (false, default) in text fields
  • id = numeric Tumblr post ID

Templates

By default, the TumblrPosts.ss include will call subsequent includes depending on post type. To customize the list container, override or create a copy of TumblrPosts. To customize the way that posts are displayed within the container, override the respective Tumblr[TYPE]Post.ss or, if you've customized the container, create your own include.

Include variables follow the syntax and structure of the Tumblr API, based on the "posts" collection of the response. See the module's default includes for examples and be aware of template context.

Caching

This module uses SS_Cache to reduce the amount of API requests. Default cache lifetime is 30 minutes. You can change this value by putting this line in your _config.php (1800 is cache lifetime in seconds):

SS_Cache::set_cache_lifetime('tumblr_api_cache', 1800, 10);

Dependencies

Uses the official Tumblr API v2 PHP Client

tkiehne-silverstripe-tumblrfeed's People

Contributors

tkiehne avatar

Watchers

James Cloos avatar helpfulrobot avatar

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.