Installation Add the package via Composer:
composer require bigfoot/content-bundle:dev-master
Register the bundle in app/AppKernel.php:
new Bigfoot\Bundle\ContentBundle\BigfootContentBundle(),
Basic Configuration
Define widgets in app/config/config.yml:
bigfoot_content:
widgets:
dashboard_header: 'AppBundle\Widget\DashboardHeaderWidget'
First Widget
Create a widget class extending AbstractWidget:
namespace AppBundle\Widget;
use Bigfoot\Bundle\ContentBundle\Model\AbstractWidget;
class DashboardHeaderWidget extends AbstractWidget {
public function getName() { return 'dashboard_header'; }
public function render() { return '<h1>Welcome!</h1>'; }
}
Accessing Pages/Static Content Use the admin interface (if available) or manually create entities via Doctrine:
php app/console doctrine:generate:entities Bigfoot\Bundle\ContentBundle\Entity
Extending AbstractWidget
Implement required methods:
class MyWidget extends AbstractWidget {
public function getName() { /* Unique slug */ }
public function render() { /* HTML output */ }
public function getTitle() { /* Display title */ }
}
Dynamic Content Fetch data via services or repositories:
public function render() {
$hotels = $this->get('hotel.repository')->findMostViewed();
return $this->renderView('widgets/most_viewed.html.twig', ['hotels' => $hotels]);
}
Twig Integration Use Twig templates for complex widgets:
public function render() {
return $this->renderView('AppBundle:Widget:my_widget.html.twig');
}
Hierarchical Pages Define parent-child relationships in the admin panel or via fixtures:
# app/fixtures/pages.yml
AppBundle\Entity\Page:
page_home:
title: Home
slug: home
parent: ~
page_about:
title: About
slug: about
parent: @page_home
Static Content Blocks Store reusable content snippets (e.g., FAQs, policies) and reference them in pages:
// In a controller
$staticContent = $this->get('bigfoot_content.static_content.manager')->findBySlug('privacy_policy');
Widget Placement
Configure widget positions in config.yml:
bigfoot_content:
dashboard:
columns: 3
widgets:
- { name: dashboard_header, position: 1 }
- { name: widget_most_viewed_hotel, position: 2 }
Admin Panel Usage Use the built-in admin interface (if enabled) to:
Widget Registration
AbstractWidget.config.yml with the exact class name (including namespace).getName() method returns a unique slug (case-sensitive).Outdated Doctrine Entities
Page or StaticContent entities not found.php app/console doctrine:generate:entities Bigfoot\Bundle\ContentBundle\Entity
php app/console doctrine:schema:update --force
Twig Template Paths
renderView() fails with "template not found."$this->renderView('@AppBundle/Widget/my_widget.html.twig');
Caching Headaches
php app/console cache:clear
Widget Debugging
Add a debug() method to your widget:
public function debug() {
return [
'name' => $this->getName(),
'config' => $this->getConfig(),
];
}
Call it via a route to inspect state.
Database Inspection
Check raw data in the bigfoot_content_widget, bigfoot_content_page, and bigfoot_content_static_content tables:
php app/console doctrine:query:sql "SELECT * FROM bigfoot_content_widget"
Event Listeners
Override widget/static content events in your bundle’s Resources/config/services.yml:
services:
app.widget.listener:
class: AppBundle\EventListener\WidgetListener
tags:
- { name: kernel.event_listener, event: bigfoot.content.widget.save, method: onWidgetSave }
Custom Widget Types
Extend AbstractWidget to add fields (e.g., setConfig(), getConfig()):
class ConfigurableWidget extends AbstractWidget {
protected $config = ['title' => 'Default'];
public function setConfig(array $config) { $this->config = $config; }
public function getConfig() { return $this->config; }
}
Admin Panel Customization
Override the admin templates in app/Resources/BigfootContentBundle/views/ to modify:
API Integration Expose widgets via a custom API endpoint:
// src/AppBundle/Controller/WidgetController.php
class WidgetController extends Controller {
public function getDashboardWidgetsAction() {
$widgets = $this->get('bigfoot_content.widget.manager')->getDashboardWidgets();
return $this->json($widgets);
}
}
Widget Positions
Static Content Slugs
$content = $this->get('bigfoot_content.static_content.manager')->findBySlug('PrivacyPolicy'); // Fails
$content = $this->get('bigfoot_content.static_content.manager')->findBySlug('privacy_policy'); // Works
Dependency Injection
WidgetContext service for shared data:
$this->get('bigfoot_content.widget.context')->set('user', $user);
How can I help you explore Laravel packages today?