2017 © Pedro Peláez
 

silverstripe-module silverstripe-navigation-scraper

image

deptinternalaffairsnz/silverstripe-navigation-scraper

  • Monday, December 14, 2015
  • by guttmann
  • Repository
  • 0 Watchers
  • 4 Stars
  • 104 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

SilverStripe Navigation Scraper

A module for SilverStripe that allows you to scrape navigation from another site and use it as navigation on your own site., (*1)

Installation

Install with composer:, (*2)

composer require 'deptinternalaffairsnz/silverstripe-navigation-scraper' '1.0.1'

Usage

Configuration

In your own config file (e.g. mysite/_config/config.yml) define the menu sets, URLs to scrape, and CSS selectors to target., (*3)

NavigationScraper:
  MenuSets:
    ScrapedFooter:
      PageToScrape: 'https://www.example.com'
      CSSSelector: '.footer-nav li a'
    ScrapedMainNav:
      PageToScrape: 'https://www.example.com'
      CSSSelector: '.header-nav li a'

Trigger a scrape

There are two options to trigger a scrape., (*4)

  1. Run the build task dev/tasks/TriggerScrapeBuildTask
  2. Install the cron task module - assuming you've configured a cron job appropriately a scrape will be run daily at 1am by default.

Templates

Use the $ScrapedMenu function in your templates, like so:, (*5)

<ul>
    <% loop $ScrapedMenu("ScrapedFooter") %>
        <li><a href="$Link">$Title</a></li>
    <% end_loop %>
</ul>

The Versions