deptinternalaffairsnz / silverstripe-navigation-scraper
Installs: 117
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 1
Open Issues: 0
Type:silverstripe-module
Requires
- fabpot/goutte: ~1.0
- silverstripe/framework: ~3.1
This package is not auto-updated.
Last update: 2024-11-23 19:00:40 UTC
README
A module for SilverStripe that allows you to scrape navigation from another site and use it as navigation on your own site.
Installation
Install with composer:
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.
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.
- Run the build task
dev/tasks/TriggerScrapeBuildTask
- 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:
<ul> <% loop $ScrapedMenu("ScrapedFooter") %> <li><a href="$Link">$Title</a></li> <% end_loop %> </ul>