Dynamic form content and tinymce in symfony - symfony

I have a tinymce issue. I use it for my textarea's in symfony. I realized following steps.
Include the tinymce JS in my base template
2 Set some configuration for tinymce
tinymce.init({
mode : "specific_textareas",
menubar: "format edit",
editor_selector : "rte",
plugins: 'emoticons textcolor',
toolbar: 'emoticons forecolor backcolor',
height : 300,
theme : 'modern'
});
Include class "rte" in my form element of type textarea
:
->add('writeto', 'collection', array(
'type' => new WritetoType() ,
'allow_add' => false,
'allow_delete' => false,
'label' => false,
'options' => array(
'required' => false,
'attr' => array('class' => ''))
))
Now everything works fine. But if i add a new collection (exp. writTo element from above) then this have not the tinymce classes. What do I wrong?
Should i start a tinymce event for dynamic content?

This part
array('class' => '')
Should contain the rte class, ie:
array('class' => 'rte')

I solved my issue.
I create a function for init my tiny mce and call this on document load:
function initRTE()
{
// Integrate tinymce into textarea
tinymce.init({
mode : "specific_textareas",
menubar: "format edit",
editor_selector : "rte",
plugins: 'emoticons textcolor',
toolbar: 'emoticons forecolor backcolor',
height : 300,
theme : 'modern'
});
}
After i add a new collection i call the init function again and my new items get the tinymce functions

Related

yii2 mpdf view displaying debug toolbar code

I'm using kartik mpdf extension to print a report. Problem is, in print view css code displaying and in footer debug toolbar code too. Please guide me how to remove that.
i'm using following code.
$content = $this->render('print', ['modelPatientTest' => $modelPatientTest]);
$pdf = new Pdf([
'mode' => Pdf::MODE_CORE, // leaner size using standard fonts
'content' => $content,
'format' => Pdf::FORMAT_A4,
'options' => [
'title' => 'Test Report',
],
'methods' => [
'SetHeader' => [''],
'SetFooter' => ['{PAGENO}|'],
]
]);
return $pdf->render();
As Debug toolbar should be active only in a development environment, put at the top of your controller's action this code:
if(YII_DEBUG === true || YII_ENV === "dev") {
Yii::$app->getModule('debug')->instance->allowedIPs = [];
}
(Edited thanks to #Gubberrr comment below)
Just change
'mode' => Pdf::MODE_CORE,
to
'mode' => Pdf::MODE_UTF8,

wkhtmltopdf (knp snappy bundle) Wrong text selection and wrong wrapping

I am use "knplabs/knp-snappy-bundle": "dev-master" for symfony 2.7
I generate pdf by using
$this->knp_snappy_pdf->generateFromHtml( $html, $file_path, $options);
Then i open pdf in chrome and try selection text i see
this
http://i.stack.imgur.com/soKJh.jpg
But if i use http://pdfcrowd.com/ and the same html i see
normal text selection
My $options
array(
'images' => true,
'no-pdf-compression' => true,
'page-width' => '150mm',
'page-height' => '180mm',
'minimum-font-size' => '2',
'dpi' => 300,
'disable-smart-shrinking' => true,
'zoom' => '0.6',
)
I can't find answer, so I use mpdf. It is better and works right out of the box immediately

Folded menu navigation with KnpMenu

I want to use KnpMenu for a current project to handle my navigation tree logic.
I have build a menu tree like this:
use Knp\Menu\Matcher\Matcher;
use Knp\Menu\MenuFactory;
use Knp\Menu\Renderer\ListRenderer;
$factory = new MenuFactory();
$menu = $factory->createItem('my_menu');
$menu->addChild('home', array('uri' => '/', 'label' => 'Home'))
->addChild('about', array('uri' => 'about', 'label' => 'About'));
$cat1 = $menu->addChild('category_1', array('uri' => 'category_1', 'label' => 'Category 1'));
$cat1_1 = $cat1->addChild('category_1_1', array('uri' => 'category_1_1', 'label' => 'Category 1.1'));
$cat1_1->addChild('category_1__1', array('uri' => 'category_1_1_1', 'label' => 'Category 1.1.1'));
$cat1_1->addChild('category_1_1_2', array('uri' => 'category_1_1_2', 'label' => 'Category 1.1.2'))->setCurrent(true);
$cat1->addChild('category_1_2', array('uri' => 'category_1_2', 'label' => 'Category 1.2'));
$renderer = new ListRenderer(new Matcher());
echo $renderer->render($menu);
I was wondering if it is possible to render a folded menu tree where only the currently active menu items are displayed. The other items should not be displayed.
In the documentation I haven't found a way to accomplish this.
Does anyone have a solution?
Thank you
Do you mean that you only want to have the menu 'unfolded' if the parent is active?
If so, then yes, I had the same requirement, and there is a PR open for it here https://github.com/KnpLabs/KnpMenu/pull/85
Currently as it's not merged I am using my branch to replace the tagged KnpMenu in composer.
//composer.json excerpt
...
"repositories": [
{
"type": "vcs",
"url": "git#github.com:catchamonkey/KnpMenu"
}
],
require: {
...
"knplabs/knp-menu": "dev-display_children_if_ancestor_current as 2.0.0",
...
}
...
You then tag the top level item with this behaviour, so to make your category_1 only expand if a child is active (or it is active), you would do
$cat1->setDisplayChildrenIfAncestorCurrent(true);
And this is handled by the twig rendered change here https://github.com/KnpLabs/KnpMenu/pull/85/files#L2R74

Text in TinyMCE textarea hidden in HTML Mode on click, ok in Visual mode

Custom wordpress form, using wp_editor, I create a Tinymce instance on the textarea.
Editor defaults to HTML but if I click into the editing area the contents disappear.
However if I switch to Visual mode, all works as expected, then switch back to HTML mode all works there too, maybe the click is being intercepted by TinyMCE?
Any clues please....
Thanks
Martin
PS initializations are:
$settings = array(
'wpautop' => true,
'media_buttons' => false,
'tinymce' => array(
'theme_advanced_buttons1' => 'bold,italic,underline,blockquote,|,undo,redo,|,fullscreen',
'theme_advanced_buttons2' => '',
'theme_advanced_buttons3' => '',
'theme_advanced_buttons4' => '',
'theme_advanced_resizing' => true,
'width' => '600px'
)
);
Such problems (besides others) may arise when a hidden textarea (or other html element) is used to init a tinymce editor. Best way to avoid this is to make it visible just before you init the editor.
I've taken a different approach and re-init the tinyMCE when switching between them. Attach it to an even handler:
var postContent = "Take Content from some hidden field, AJAX call, etc.";
if ( tinyMCE
&& tinyMCE.activeEditor
&& tinyMCE.activeEditor.id )
{
tinyMCE.activeEditor.setContent( postContent, {} );
tinymce.execCommand( 'mceRemoveControl', true, tinyMCE.activeEditor.id );
}

writing views style plugin -error - Display "Master" has an invalid style plugin

I'm writing a views display plguin, I defined it as follows in mymodule.views.inc
function mymodule_views_plugins() {
$plugins['style']['mymodule_articles_list'] = array(
'title' => t('mymodule Articles Listing'),
'help' => t('Display Articles using citation'),
'path' => drupal_get_path('module', 'mymodule'),
'handler' => 'mymodule_articles_list_style_plugin',
'uses row plugin' => TRUE,
'uses options' => TRUE,
'uses grouping' => FALSE,
'type' => 'normal',
'use pager' => FALSE,
'use ajax' => FALSE,
'theme' => 'mymodule_articles_list'
);
return $plugins;
}
I created class and theme functions. When I select 'mymodule Articles Listing' while created view I get error
Display "Master" has an invalid style plugin. Display "Page" has an
invalid style plugin.
Upate 1
While running in devel execute php
$style_plugin = views_get_plugin('style','mumodule_articles_list');
does not return any thing, which means there is something wrong with definition
The first error is returned from views_plugin_display::validate(), which executes the following code.
$style = $this->get_plugin();
if (empty($style)) {
$errors[] = t('Display "#display" has an invalid style plugin.', array('#display' => $this->display->display_title));
}
The code that views_plugin_display::get_plugin() executes when it is called without arguments is practically the following one.
$name = $this->get_option('style_plugin');
$plugin = views_get_plugin('style', $name);
if (!$plugin) {
return;
}
That code fails when views_get_plugin() doesn't find the plugin definition for $name, which could happen when it doesn't find the file containing the handler, or the name returned from views_plugin_display::get_option() is wrong.

Resources