bibsdb/citation-portrait-bundle
Installation
Add the repository to composer.json under "repositories":
"repositories": {
"bibsdb/citation-portrait-bundle": {
"type": "vcs",
"url": "https://github.com/bibsdb/citation-portrait-bundle"
}
}
Require the bundle:
composer require bibsdb/citation-portrait-bundle
Enable the Bundle
Register in config/bundles.php (Laravel 5.5+) or AppKernel.php (older versions):
Bibsdb\CitationPortraitBundle\BibsdbCitationPortraitBundle::class => ['all' => true],
Load Templates Run the template loader command:
php artisan bibsdb:core:templates:load
Admin Setup Enable the template in the admin panel (check the bundle’s documentation for UI-specific steps).
Use the bundle’s Twig template to embed a video in a view:
{{ bibsdb_citation_portrait({
'video_id': 'YOUR_VIDEO_ID',
'width': 640,
'height': 360
}) }}
Replace YOUR_VIDEO_ID with a valid ID from citation-portrait.com.
Dynamic Video IDs Pass video IDs dynamically from a database or API:
// Controller
return view('show', ['videoId' => $paper->citationPortraitId]);
{{ bibsdb_citation_portrait({
'video_id': videoId,
'autoplay': false
}) }}
Custom Styling Override the default template by extending the base template:
{% extends 'BibsdbCitationPortraitBundle::default.html.twig' %}
{% block video_container %}
<div class="custom-video-wrapper">
{{ parent() }}
</div>
{% endblock %}
Conditional Rendering Use Twig logic to show/hide based on data:
{% if paper.hasCitationPortrait %}
{{ bibsdb_citation_portrait({'video_id': paper.citationPortraitId}) }}
{% endif %}
Asset Management
The bundle relies on player.js from CitationPortrait. Ensure your webpack.mix.js or asset pipeline includes:
mix.js('node_modules/citation-portrait/player.js', 'public/js');
Or use a CDN:
<script src="https://cdn.citation-portrait.com/player.js"></script>
Laravel Mix/Webpack
If using Laravel Mix, alias the player in webpack.mix.js:
mix.alias({
'citation-portrait': path.resolve(__dirname, 'node_modules/citation-portrait/player.js')
});
API-Driven IDs Fetch video IDs via an API (e.g., from a research paper database) and pass them to the template:
$videoId = $apiClient->getCitationPortraitId($paper->doi);
Ads and Controls
Template Loading
php artisan bibsdb:core:templates:load after installation.Missing JavaScript
player.js.CORS Restrictions
Check Console Logs
Open browser dev tools (F12) to inspect errors like:
Uncaught ReferenceError: CitationPortraitPlayer is not defined
→ Indicates player.js is missing or loaded after the template.
Validate Video IDs Test IDs manually on citation-portrait.com to confirm they work outside Laravel.
Clear Cache After template updates, clear Laravel’s cache:
php artisan cache:clear
php artisan view:clear
Custom Player Options Extend the player config by overriding the Twig block:
{% block player_options %}
{{ parent() }}
{{ {
'customOption': true,
'volume': 0.5
}|json_encode|raw }}
{% endblock %}
Event Listeners Hook into the bundle’s events (if documented) to modify behavior, e.g., post-video-load actions.
Localization
Override translation files in resources/lang/vendor/bibsdb to customize labels (e.g., "Play Video").
Batch Processing Use the bundle in loops for research paper galleries:
{% for paper in papers %}
{{ bibsdb_citation_portrait({'video_id': paper.videoId, 'width': 400 }) }}
{% endfor %}
Fallback Content Provide fallback HTML/placeholders if the video fails to load:
{% set portrait = bibsdb_citation_portrait({'video_id': videoId }) %}
{% if portrait is empty %}
<div class="fallback">Video unavailable. View on {{ citationPortraitLink(videoId) }}.</div>
{% else %}
{{ portrait }}
{% endif %}
Performance Lazy-load videos for better page performance:
{{ bibsdb_citation_portrait({
'video_id': videoId,
'loading': 'lazy'
}) }}
How can I help you explore Laravel packages today?