1. Go to this page and download the library: Download comur/content-admin-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
comur / content-admin-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
// ...
new Comur\ContentAdminBundle\ComurContentAdminBundle(),
];
// ...
}
// ...
}
use Comur\ContentAdminBundle\Entity\AbstractInlineContent;
class MyContentEntity extends AbstractInlineContent {
//...
}
use Comur\ContentAdminBundle\Form\InlineContentType;
//...
protected function configureFormFields(FormMapper $formMapper): void
{
$formMapper
//...
->add('content', InlineContentType::class, array(
'template_field_name' => 'template', // this will get template name from another field inside the same form (default is template)
'template' => 'frontend/index.html.twig', // optional, you must specify either one of template_field_name or template parameter
'class' => Page::class, // classname of your entity
'locales' => array('en', 'fr'), // Or pass a parameter (optional, you can globally configure it in yaml and override it here)
'
// App/Controller/FrontController.php
namespace App\Controller;
use App\Entity\Page; // This is my entity extending ComurContentAdmin's AbstractInlineContent entity
use Symfony\Component\HttpFoundation\Request; // Handle the request in the controller
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class FrontController extends AbstractController
{
public function index(Request $request, $slug) {
$page = $this->getDoctrine()->getManager()->getRepository(Page::class)->findOneBySlug($slug);
return $this->render('frontend/index.html.twig', array(
'content' => $page->getContent($request->getLocale()) // This will return localized content data as an array and twig filter will replace default content of your template with this
));
}
}
use Comur\ContentAdminBundle\Form\InlineContentType;
//...
protected function configureFormFields(FormMapper $formMapper): void
{
$myEntity = $this->getMyEntity(); // Change it :)
$formMapper
//...
->add('content', InlineContentType::class, array(
'template_field_name' => 'template', // this will get template name from another field inside the same form (default is template)
'template' => 'frontend/index.html.twig', // optional, you must specify either one of template_field_name or template parameter
'class' => Page::class, // classname of your entity
'locales' => array('en', 'fr'), // Or pass a parameter (optional, you can globally configure it in yaml and override it here)
' 'generateFilename' => true //optional
),
'cropConfig' => array(
'minWidth' => 588,
'minHeight' => 300,
'aspectRatio' => true, //optional
'cropRoute' => 'comur_api_crop', //optional
'forceResize' => false, //optional
'thumbs' => array( //optional
array(
'maxWidth' => 180,
'maxHeight' => 400,
'useAsFieldImage' => true //optional
)
)
)
)
))
//...
;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.