How load extra plugins for Zend Dojo Form Element Editor? - zend-form

I have simple Zend_Dojo_Form with Editor element, when I add aditional plugins I got notice from firebug
Cannot find plugin linkdialog
the code
class Some_Form extends Zend_Dojo_Form
{
public function init() {
$this->addElement('Editor', 'content', array(
'label'=> 'Some editor title',
'dijitParams' => array(
'extraPlugins'=>array('linkdialog')
),
);
}
}
How I can enable aditional plugins for Zend_Dojo_Form_Element_Editor? I tried to include manualy, but same results.
dojo.require("dijit._editor.plugins.LinkDialog");
any suggestions?

Thanks #Alan Kay, you got me on the right track, but to elaborate a little more.
There seems to be two categories of Dojo editor plugins, '(built-in) plugins' and 'extraPlugins'.
Here's a list of built-in plugins (unsure if it's up-to-date). You can add built-in plugins on Dojo enabled Zend Forms Elements fine:
$this->addElement('editor', 'summary', array(
'label' => 'Summary:',
'plugins' => array(
// NOTE: specifying any will lose the default builtin plugins,
// so need to re-add the ones you want.
// Builtin plugins
'bold', 'italic', 'underline', '|',
'insertOrderedList', 'insertUnorderedList', '|',
'indent', 'outdent', '|',
'justifyLeft', 'justifyRight', 'justifyCenter', 'justifyFull', '|',
// dijit._editor.plugins that work
'foreColor', 'hiliteColor', '|', // TextColor
'fontName', 'fontSize', 'formatBlock', '|', // FontChoice
'createLink', 'insertImage', '|', // LinkDialog
'viewSource', // ViewSource
)
));
Alternatively, there are two main libraries of extraPlugins, Dijit (http://dojotoolkit.org/reference-guide/dijit/_editor/plugins.html#dijit-editor-plugins) and Dojox (http://dojotoolkit.org/reference-guide/dojox/editor/plugins.html#dojox-editor-plugins). Unfortunately, 'extraPlugins' are unavailable in Zend Framework until the next minor release (1.12) ZF-11511. You could use the patch to create your own library to extend Zend_Dojo_Form_Element_Editor in the meantime.
Note, when specifying 'extraPlugins', you want to use the 'short name' (e.g. 'createLink'), not the 'resource' (e.g. 'linkdialog'):
"The bolded text represents the resource; the basic text represents the
"short name" to be added to the extraPlugins list." 'Using Plugins' (http://dojotoolkit.org/documentation/tutorials/1.6/editor/)
However, note in the above example, it's possible to include the 'short names' for some Dijit extraPlugin 'resources', but not Dojox to my knowledge. Unsure why this is (haven't looked into dojo src - anyone?). Try your luck.

I don't know if this will work for your exact syntax, but you don't want to set 'LinkDialog', you want 'createLink'. I'm guessing 'extraPlugins'=>array('createLink') is the change you need
I know the following works for me:
$this->addElement(new Zend_Dojo_Form_Element_Editor('content',
array(
'label' => 'Content:',
'class' => 'soria',
)
)
);
$this->contents->addPlugins(array('|', 'createLink');

Related

Drupal9: Saving form as node in SQL (custom module example)

i develop a custom module with forms to save data in SQL-Datebase. I want to use for that the node-structure.
Normal SQL-savings for example table works but not for the node-tables.
Any idea what is going wrong?
This ist my Code for saving, which works in non-node-tables:
public function submitForm(array &$form, FormStateInterface $form_state) { $connection = \Drupal::service('database');
$result = $connection->insert('node.node__body')
->fields(['body_value'])
->values([
'body_value' => 'text for body',
])
->execute();
$form_state->setRedirect('modulname.form');
}
Use Entity API in Drupal to manipulate or create a node.
In your case,
$node = \Drupal::entityTypeManager()->getStorage('node')->create(
[
'type' => 'page',
'title' => 'New Basic Page',
'body' => 'text for body'
]
);
Here, type is the content type machine name. Don't forget to update with your own. Also you probably want to inject the entity_type.manager service and use in the code.
Get more info here: Working with entities in Drupal

Prestashop adding css issue

I try to add external css but is not work property,
I am use prestashop version 1.7.4.3
in install() function I call the hooks
&& $this->registerHook('displayHeader')
&& $this->registerHook('backOfficeHeader')
inside the hook, i registering the css and js files
public function hookDisplayHeader($params)
{
$this->context->controller->addCSS(($this->_path) .'views/css/style.css');
$this->context->controller->addJS(($this->_path) .'views/js/script.js');
$this->context->controller->addCSS('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
}
public function hookBackOfficeHeader(){
$this->context->controller->addCSS('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
$this->context->controller->addCSS(($this->_path) .'views/css/module.css');
$this->context->controller->addJqueryUI('ui.sortable');
}
in hookBackOfficeHeader() I don't have any problem, but in hookDisplayHeader() doesn't want to register font awesome.
I try to use registerStylesheet() instead to addCss() but is not working at all.
Why this different between the two functions? it is, maybe because hookDisplayHeader doesn't accept external file?
Thank you
edit:
I solved with registerStylesheet() and registerJavascript()
public function hookDisplayHeader($params)
{
$this->context->controller->registerStylesheet(
'sidemenu',
($this->_path) .'views/css/style.css',
['server' => 'remote', 'position' => 'head', 'priority' => 150]
);
$this->context->controller->registerJavascript(
'sidemenu-js',
($this->_path) .'views/js/script.js',
['server' => 'remote', 'position' => 'head', 'priority' => 120]
);
$this->context->controller->registerStylesheet(
'remote-font-awesom',
'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css',
['server' => 'remote', 'position' => 'head', 'priority' => 20]
);
}
Also for adding font-awesome you better to use requireAssets(array('font-awesome')) something like this
$this->context->controller->requireAssets(array('font-awesome'));
Backward compatibility is kept for the addJS(), addCSS(), addJqueryUI() and addJqueryPlugin() methods. Incidentally, now is the best time to update your libraries and use the new method.
When developing a PrestaShop module, you may want to add specific styles for your templates. The best way is to use the registerStylesheet and registerJavascript methods provided by the parent FrontController class.
Look link : https://devdocs.prestashop.com/1.7/themes/getting-started/asset-management/
Regards

Accessing content of textarea in Drupal-7-Theme-Form

in my custom theme-settings.php (zen-subtheme) i put following code to get a new textarea with textformat in my theme-settings:
<?php
function paper_form_system_theme_settings_alter(&$form, &$form_state) {
$form['paper_data'] = array(
'#type' => 'text_format',
'#title' => 'Put Text in here:',
'#rows' => 5,
'#resizable' => FALSE,
'#default_value' => 'xyz..',
'#format' => 'full_html'
);
}
the form is working perfektly, but when i want to access the variable by writing
<?php
$pdata = theme_get_setting('paper_data');
echo $pdata;
?>
in my page.tpl.php, the content of the variable is not rendered - instead the word "Array" is printed ...
What's wrong and why? (If i use 'textarea' as type instead of 'text_format', all is rendered well.)
You will understand when you use something like the Devel module's dpm() function to check the variable rather than echo(). Coding Drupal without the Devel module is, IMHO, folly.
The issue very likely stems from your use of the text_format type. As you can see, it saves both the textarea value as well as an associated text format. When this is used Drupal returns the data in structured form which varies depending on the type of format.
dpm() is your friend :)

Always show Pager on CGridView?

I've build a CGridView menu, and I want to always display the pager
(even when it's showing all the data and the navigation is not needed)
This is the current code I have:
$this->widget('zii.widgets.grid.CGridView',
array('dataProvider'=>$search,
'columns' => $columns,
'itemsCssClass' => 'list_table',
'template' => '{pager}{summary}{items}',
'pager' => array(
'cssFile'=>false,
'class'=>'CLinkPager',
'firstPageLabel' => '<<',
'prevPageLabel' => '<',
'nextPageLabel' => '>',
'lastPageLabel' => '>>',
'header' => '',
'footer' => $footer_btns,
),
'pagerCssClass' => 'pagination',
));
You could do this by overriding the renderPager() method -- however, it seems that the pager gets put together in a few files so one way to do it by only overriding one class would be to:
override zii.widgets.grid.CGridView to add your custom renderPager() method with something like:
Yii::import('zii.widgets.grid.CGridView');
class MyGrid extends CGridView {
public function renderPager() { ... }
}
the default renderPager() function is here.
What you want to do is look for the line that tests for pager content:
if($pager['pages']->getPageCount()>1) {
and change the "else" statement to put in your default "empty" pager content, which could use the same <ul> structure. Since you are not providing any navigation for the blank view, you don't need to worry about that data if this is used in multiple places. That could look something like:
else {
echo '<div class="'.$this->pagerCssClass.'">';
## YOUR CUSTOM "EMPTY PAGER" HTML HERE ##
echo '</div>';
}
You might need to define a couple extra css classes as well. On pages where only part of the pagination is showing (e.g., the first and last page), you can use CSS to redefine the ".hidden" class(es).

Remove line numbers from SyntaxHighlighter

Is there any way to remove the line numbers of SyntaxHighlighter?
Thanks!
You can set the SyntaxHighliter's gutter configuration to false. This will remove the line number from your code.
<pre class="brush: java; gutter: false;"></pre>
Hit the "view plain" link?
Taking a look at the SyntaxHighlighter demo you will see it has buttons in the top right corner which you can click to either copy the code to your clipboard, see the actual source code (removing markup) and or print it.
Are you asking us how to remove the actual feature that adds the line numbers while still keeping the rest of the functionality in place? Are you asking us to do this for you?
In response to comment:
If you want to keep the functionality in place, and just remove the line numbers you will need to download a copy of the javascript file for yourself and remove the features you don't want. the SyntaxHighlighter download page allows you to download your very own version of the highlighter, it also tells you that is is licensed under the LGPL 3, which means you have to follow those rules when you make and use your modifications.
If you want, you may come back and ask individual Javascript questions, if you get stuck in a particular spot, but we are not TopCoder nor will we re-write code for you.
If you don't want to edit your existing markup, you can turn it off globally by editing the shCore.js file:
var sh = {
defaults : {
...
...
...
/** Enables or disables gutter. */
'gutter' : false,
...
...
...
},
...
...
...
}
You can set the default of 'gutter' => 0 in SyntaxHighlighter Evolved version 3.2.1 by editing the file syntaxhighlighter.php. Look for this in the file:
// Create array of default settings (you can use the filter to modify these)
$this->defaultsettings = (array) apply_filters(
'syntaxhighlighter_defaultsettings', array(
'theme' => 'default',
'loadallbrushes' => 0,
'shversion' => 3,
'title' => '',
'autolinks' => 1,
'classname' => '',
'collapse' => 0,
'firstline' => 1,
'gutter' => 0,
'htmlscript' => 0,
'light' => 0,
'padlinenumbers' => 'false',
'smarttabs' => 1,
'tabsize' => 4,
'toolbar' => 0,
'wraplines' => 1, // 2.x only
) );