alphalemon/app-business-dropcap-bundle
git clone https://github.com/alphalemon/AlphaLemonCmsSandbox.git
cd AlphaLemonCmsSandbox
composer require alphalemon/app-business-dropcap-bundle
app/AppKernel.php:
new AlphaLemon\Business\DropCapBundle\AlphaLemonBusinessDropCapBundle(),
php app/console cache:clear --env=dev
Add a DropCap Field to a Content Type:
Extend an existing content type (e.g., Page) by adding the DropCap field in the CMS admin panel under "Content Types" > [Your Type] > "Fields".
first, all, or custom CSS classes).Render DropCaps in Templates: Use the Twig extension provided by the bundle:
{{ alphalemon_dropcap(content.title, 'first') }}
(Replace 'first' with 'all' or a custom class like 'custom-class' if configured.)
Content Type Integration:
{% for article in articles %}
<h2>{{ article.title|alphalemon_dropcap('first') }}</h2>
{{ article.content }}
{% endfor %}
Dynamic Styling:
dropcap-large and style it in your theme’s CSS:
.dropcap-large:first-letter {
font-size: 4em;
float: left;
line-height: 1;
margin-right: 0.1em;
}
Reusable Components:
{% macro dropCapTitle(title, style) %}
<h2>{{ title|alphalemon_dropcap(style) }}</h2>
{% endmacro %}
{{ form_row(form.title) }}
<h2>{{ form.title.vars.data|alphalemon_dropcap('first') }}</h2>
// In a serializer
$normalizer->ignoreNull();
$normalizer->setIgnoredAttributes(['dropCapStyle']);
trans('DropCapBundle::dropcap.label')).Bundle Compatibility:
AlphaLemonCmsBundle is installed and configured. Missing dependencies will cause ClassNotFound errors.Caching Issues:
php app/console cache:clear --env=all
app/config/config.yml for twig extensions).Field Configuration:
AppKernel.php.Twig Filter Scope:
alphalemon_dropcap filter is Twig-only. Avoid using it in PHP templates or non-Twig contexts (e.g., Blade in Lumen).app/config/config_dev.yml) and inspect app/logs/dev.log for:
ClassNotFoundException: Missing bundle or dependency.RuntimeException: Invalid drop cap style or malformed input.// In a controller or CLI command
$twig = $this->get('twig');
dump(get_class_methods($twig->getExtension('alphalemon_dropcap')));
Custom Drop Cap Styles: Extend the bundle’s default behavior by creating a custom Twig extension:
// src/AlphaLemon/YourBundle/Twig/DropCapExtension.php
class DropCapExtension extends \Twig_Extension
{
public function getFilters()
{
return [
new \Twig_SimpleFilter('custom_dropcap', [$this, 'renderDropCap']),
];
}
public function renderDropCap($text, $style = 'first')
{
// Custom logic (e.g., add icons, colors)
return '<span class="dropcap-'.$style.'">'.$text.'</span>';
}
}
Register it in services.yml:
services:
your_bundle.dropcap_extension:
class: AlphaLemon\YourBundle\Twig\DropCapExtension
tags:
- { name: twig.extension }
Performance:
// Add this to your theme's JS
document.querySelectorAll('.dropcap').forEach(el => {
el.innerHTML = el.textContent.replace(/^([^\s]+)/, '<span class="dropcap-first">$1</span>');
});
float or grid to prevent layout shifts caused by drop caps.Testing:
first-letter behave differently in older browsers).// Example functional test
$client = static::createClient();
$crawler = $client->request('GET', '/admin/content-types');
$this->assertContains('DropCap Title', $crawler->html());
How can I help you explore Laravel packages today?