I need some data added default in the editor.
Like I want a template to get loaded in editor when I click on edit template option..
Can anyone suggest me some tip??
Here you can see how it can be done
$dataa= $this->getTemplate1();
$fieldset->addField('content', 'editor', array(
'name' => 'content',
'label' => Mage::helper('abandonedcart')->__('Content'),
'title' => Mage::helper('abandonedcart')->__('Content'),
'style' => 'width:700px; height:500px;',
'wysiwyg' => true,
'required' => true,
'state' => 'html',
'config' => $wysiwygConfig,
'value'=> $dataa,
));
if (Mage::getSingleton('adminhtml/session')->getAbandonedcartData()) {
$form->addValues(Mage::getSingleton('adminhtml/session')->getAbandonedcartData());
Mage::getSingleton('adminhtml/session')->setAbandonedcartData(null);
} elseif (Mage::registry('abandonedcart_data')) {
$form->addValues(Mage::registry('abandonedcart_data')->getData());
}
return parent::_prepareForm();
}
and calling a function to have data
public function getTemplate1() {
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('abandonedcart_abandonedcart_group_email_template');
$emailTemplate['template_text'];;
$template_id = Mage::getStoreConfig('abandonedcart/abandonedcart_group/email_template');
$emailTemplate = Mage::getModel('core/email_template')->loadDefault($template_id);
return $processedTemplate = $emailTemplate->getProcessedTemplate();
}
Related
I'm developing an prestashop module and it's just a beginning.
The problem is in the configuration page of my module.
I append some text boxes and the label and description are visible, but the textbox is not visible.
I have looked many other examples but haven't found yet any differences and what is wrong.
Mystery is that if I change the type to date or file, it's visible.
// This function called in getContent() of main module php file.
public function displayForm()
{
$fields_form = array(
'form' => array(
'legend' => array(
'title' => $this->trans('*'),
),
// Here is the textbox.
'input' => array(
array(
'type' => 'text',
'label' => $this->trans('Link:'),
'name' => 'LINK_PRODUCT',
'desc' => $this->trans('Please input the link...'),
'lang' => true,
'required' => true
)
),
'submit' => array(
'title' => $this->trans('Save'),
'class' => 'btn btn-default pull-right'
)
)
);
$helper = new HelperForm();
$helper->module = $this;
$helper->name_controller = $this->name;
$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex . '&configure=' . $this->name;
$helper->title = $this->displayName;
$helper->show_toolbar = false;
$helper->submit_action = 'submit';
$helper->fields_value['LINK_PRODUCT'] = Configuration::get('LINK_PRODUCT');
return $helper->generateForm(array($fields_form));
}
I would like to make the textbox visible, how should I go about doing this?
You want to have multilingual so you need to define which language is a default. Add this code to your helper definition
$helper->default_form_language = $this->context->language->id;
and replace
$helper->fields_value['LINK_PRODUCT'] = Configuration::get('LINK_PRODUCT');
with
$helper->tpl_vars = array(
'fields_value' => array('LINK_PRODUCT' => Configuration::get('LINK_PRODUCT')),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
to define all available languages and values of your LINK_PRODUCT variable.
And also, don't forget that you work with multilingual field and you need to have an array with values for your variable. So during extracting and saving you need to treat them as values for all languages. For example, if you have three languages available you need to get three values. The best way to get them is
$values = [];
foreach ($this->context->controller->getLanguages() as $language) {
$values[$language['id_lang']] = Configuration::get('LINK_PRODUCT', $language['id_lang']);
}
$helper->tpl_vars = array(
'fields_value' => array('LINK_PRODUCT' => $values),
'languages' => $this->context->controller->getLanguages(),
'id_language' => $this->context->language->id,
);
and when you will save it use similar combination but with updateValue
I've built a Wordpress plugin, and now I want to add support for Visual Composer but I can't get it to work. I've read a lot of articles about how to use vc_map, found pages on github with examples, and it seems like I do everything like described in these articles. However my shortcodes still don't show up in the VC editor.
My shortcode (it works perfectly as a shortcode, [mappy id="123"] will show the map with the ID of 123)
add_shortcode('mappy', 'mappy_shortcode');
function mappy_shortcode($atts) {
// Attribute defaults
extract(shortcode_atts(array(
'id' => null,
), $atts));
// Check if id is set, and the given post is a mappy_map
if(!isset($atts['id'])) {
return '';
}
$post = get_post(intval($atts['id']));
if(!isset($post)) {
return;
}
if($post->post_type != 'mappy_map') {
return;
}
return $post->post_content;
}
And the code I've tried:
/**
* Visual Composer Support
*/
if(defined('WPB_VC_VERSION')) {
add_action('vc_before_init', 'mappy_vc_support');
}
function mappy_vc_support() {
vc_map(
array(
'base' => 'mappy',
'description' => __('Display a Mappy map.', 'mappy'),
'category' => 'Mappy',
'icon' => plugin_dir_url(__FILE__) . 'img/vc_map_32.png',
'class' => '',
'weight' => 100,
'params' => array(
array(
'type' => 'dropdown',
'class' => '',
'heading' => __('Térkép', 'mappy'),
'param_name' => 'id',
'value' => mappy_map_list(),
'description' => __('Térkép', 'mappy'),
'holder' => 'div'
)
)
)
);
}
/**
* Helper function to get all mappy_map posts
*/
function mappy_map_list() {
$list = array();
$posts = get_posts(array('post_type' => 'mappy_map'));
foreach($posts as $post) {
$list[$post->post_title] = $post->ID;
}
return $list;
}
I've also tried to hook mappy_vc_support into init and admin_init, with no luck.
Also note that the function vc_map itself is being called, and returns 1.
What could be the problem here?
I am trying to style the check symbol (✓) in my member profile tab on a Buddypress site. The tab is created in my functions.php file in my child theme shown in the code below. I want to make the check symbol green and bold. Because this is in PHP and part of a function I don't know how to accomplish this. Any ideas would be appreciated.
add_action('after_setup_theme','kleo_my_custom_tabs');
function kleo_my_custom_tabs()
{
global $bp_tabs;
$bp_tabs = array(); $bp_tabs['verify'] = array(
'type' => 'regular',
'name' => __('Verified ✓', 'kleo_framework'),
'group' => 'Verify',
'class' => 'regulartab'
);
}
Try this:
'Verified <b style=\'color:#009900;\'>✓</b>'
add_action('after_setup_theme','kleo_my_custom_tabs');
function kleo_my_custom_tabs()
{
global $bp_tabs;
$bp_tabs = array(); $bp_tabs['verify'] = array(
'type' => 'regular',
'name' => __('Verified <b style="color:green;">✓</b>', 'kleo_framework'),
'group' => 'Verify',
'class' => 'regulartab'
);
}
I have a content type (budget), it is a custom content type
function budget_node_info() {
return array(
'budget' => array(
'base' => 'budget',
'name' => t('Budget'),
'description' => t('Represents individual budget.'),
'title_label' => t('Budget Name'),
'locked' => TRUE
)
);
}
also I have the form function
function budget_form($node, $form_state) {
drupal_add_library('system', 'ui.tabs');
drupal_add_library('budget', 'highcharts');
drupal_add_js(drupal_get_path('module', 'budget') . '/js/budget_base.js');
drupal_add_js(drupal_get_path('module', 'budget') . '/js/' . $node->type . '.js');
$form = node_content_form($node, $form_state);
$config = variable_get($node->type);
I want to show the edit form on the node view page (I want to show form from node/[nid]/edit to node/[nid])?
I tried next:
function budget_node_view($node, $view_mode, $langcode){
$node->content['edit-form'] = array(
'#markup' => render(drupal_get_form('budget_form', $node)),
'#weight' => 10,
);
}
also I tried
function budget_node_view($node, $view_mode, $langcode){
$node->content['edit-form'] = array(
'#markup' => render(budget_form($node, array())),
'#weight' => 10,
);
}
2nd version show form but without any js or css loaded.
What am I doing wrong?
I used function node_page_edit($node) and seems like it works
function wp_budget_node_view($node, $view_mode, $langcode){
module_load_include('inc', 'node', 'node.pages');
$node->content['edit-form'] = array(
'#markup' => render(node_page_edit($node)),
'#weight' => 10,
);
}
also for new (empty) form you should use node_add function function node_add($type
First, actually I'm not using CGridView, but I'm using TbExtendedGridView from YiiBooster. I use CGridView on the title because it's more familiar, but still these two things works in quite the same way.
I'm enabling inline edit on my TbExtendedGridView (TbJEditableColumn). TbExtendedGridView is using jquery's Jeditable for this functionality. This Jeditable also applicable to CGridView.
Thanks to this SO's question: Change the Row Color Based on the Column value in CGridView
I know how to change the row color. But, it's still not working with the inline edit functionality. So, my question is, how can that rowCssClassExpression be updated everytime I edit some value on a column?
This is my view's code on [root]/protected/views/transaction/admin.php
<?
$this->widget('bootstrap.widgets.TbExtendedGridView', array(
'id'=>'transaction-grid',
'rowCssClassExpression'=>'$data->getCssClass()',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name'=>'date',
'value'=> 'date("j M Y", strtotime($data->date))',
'htmlOptions' => array('style'=>'width:52px')
),
array(
'name' => 'amount',
'value' => 'number_format($data->amount, 0, ",", ".")',
'htmlOptions' => array('class'=>'currency', 'style'=>'width:72px')
),
array(
'name' => 'category_name',
'value'=>'$data->category->name',
'header'=>'Category',
'sortable' => 'true',
'htmlOptions' => array('style'=>'width:131px'),
'class'=>'bootstrap.widgets.TbJEditableColumn',
'jEditableOptions' => array(
'type' => 'optgroup',
'loadurl' => Yii::app()->baseUrl . '/index.php/transaction/getCategory',
'submitdata' => array('attribute'=>'category'),
'cssclass' => 'form',
'width' => '180px',
'submit' => 'save changes'
)
),
array(
'name'=>'desc',
'value'=>'$data->desc',
'htmlOptions' => array('class'=>'desccell'),
'class'=>'bootstrap.widgets.TbJEditableColumn',
'jEditableOptions' => array(
'type' => 'text',
// very important to get the attribute to update on the server!
'submitdata' => array('attribute'=>'desc'),
'cssclass' => 'form',
'width' => '180px',
)
),
array(
'htmlOptions' => array('nowrap'=>'nowrap'),
'class'=>'bootstrap.widgets.TbButtonColumn',
)
)
)
And this is my getCssClass code on [root]/protected/models/Transaction.php:
public function getCssClass(){
$categoryType = Category::model()->findByPk($this->categoryId)->getAttribute("type");
$categoryName = Category::model()->findByPk($this->categoryId)->getAttribute("name");
$class = "";
if($categoryName == "Uncategorized Income"){
$class = "darkgreen";
}
else if($categoryName == "Uncategorized Expense"){
return "darkred";
}
else if($categoryType == "INCOME"){
return "green ";
}
else if($categoryType == "EXPENSE" || $categoryType == "COST OF GOODS"){
return "red ";
}
else if($categoryType == "WITHDRAW" || $categoryType == "DEPOSIT" ){
return "blue ";
}
else{
return "grey ";
}
return $class . " " . $categoryName . " " . $categoryType;
}
Use the 'afterAjaxUpdate' attribute to fire a javascript function on any update.
'afterAjaxUpdate' => ' function(){ //enterJScode }',