Elementor custom category not showing up in edit panel - elementor

Im trying to build a custom Elementor widget in my own category, but when I created a custom category, it was not displayed in the edit panel, which means I have to search my widget name to find it.
Does any know how to fix it?
The code:
function add_elementor_widget_categories() {
\Elementor\Plugin::instance()->$elements_manager->add_category(
'category-name',
[
'title' => __( 'Test Category', 'plugin-name' ),
'icon' => 'fa fa-plug',
]
);
}
add_action( 'elementor/elements/categories_registered', 'add_elementor_widget_categories' );
This code is from Elementor sample code, but I don't know why it doesn't work.

Related

Hook into elementor widget?

I am trying to find a hook that will let me add my own code into an existing elementor widget. For example they have the "post widget" which lets you display a list of posts based on the conditions/categories you set.
I would like to add my own code into this "block" but am unable to find any specific hooks for hooking into an existing widget (specifically the posts widget)
Any help would be much appreciated. Is there a hook for this? If not what is my next best option?
Thanks!
This depends on what you want to achieve but in general there are hooks.
I am not sure about the posts-widget but I can show you some examples in general.
If you want to add controls to a widget use this (you can find additional information to the names and stuff in their documentation https://developers.elementor.com/add-controls-to-widgets/)
add_action( 'elementor/element/heading/section_title/before_section_end', function( $element, $args ) {
$element->add_control( 'title_color',
[
'label' => 'Color' ,
'type' => \Elementor\Controls_Manager::SELECT,
'default' => 'red',
'options' => [
'red' => 'Red',
'blue' => 'Blue',
],
'section' => 'section_title',
'tab' => 'content',
]
);
}, 10, 2);
the widget in the example is the heading. You can find out the registered names by inspecting the editor or the blocks inside the plugin directory
If you want to change the rendered content of a widget you can use this
add_action( 'elementor/widget/render_content', function( $content, $widget ){ // $content (string) = the rendered content of the widget; widget = the data object
if ($widget->get_name() === 'heading') { // your targeted widget
$settings = $widget->get_settings(); // every that is stored in this method. Titles, captions, margins and so on. Usually this is all you need
// eg if you simply want to wrap your widgets content you can do something like this
$content .= '<div class="i-am-a-wrapper">'.$content.'</div>';
}
return $content;
}, 10, 2 );
I hope this helps :)

hook_action_info does not create its VBO list item in view

I am trying to code my custom action using views and VBO.
The my view shows the user a list of commerce line items.
Here the code:
function nlmcode_action_info() {
return array(
'vbo_download_pdf' => array(
'type' => 'entity',
'label' => t('Download PDF'),
'configurable' => FALSE,
'triggers' => array('any')
),
);
}
function vbo_download_pdf($entity, $context) {
dpm("Do the magic here.");
}
I then can see the bulk operation available in the select field but once I have selected my custom 'Download PDF' option and added to the view, the item is missing in the VBO drop down list.
Solved.
Permissions to 'Download PDF' have to be set.

Different Title for Different Radio buttons in Cakephp form helper

How can i give different title for different radio button using CakePHP Form Helper
$radio_options = array('unknown'=>'Unknown','negative'=>'Negative','positive'=>'Positive');
$titles = array('0'=>'Unknown','1'=>'Negative','2'=>'Positive');
I am trying to create radio buttons like this
echo $this->Form->input('radio_buttons', array(
'options' => $radio_options,
'legend' =>false,
'label' => true,
'div'=>false,
'class'=>'radio inline',
'type' => 'radio',
'separator'=>'<br>',
'title'=>$titles,));
But its not working..Form Helper creating same title for all of the radio buttons.
Look at what the FormHelper generates, then generate it manually or with a php foreach loop or something.
There are cases like this, when it's just easier (or the only way) to not use a helper.

Is it possible to create a checkbox with images along with the text in the labels in cakephp?

Somebody please give me ideas on this!I would like to generate multiple checkboxes with an image along with the text in the label. I have created a field called solutioncheckbox in the Contact form for Checkbox. My code is as below for creating multiple Checkboxes
<?php echo $this->Form>input('solutioncheckbox',array('label'=>false,'type'=>'select','class'=>'solution','multiple'=>'checkbox','options'=>array(1=>'WEB DESIGN',2=>'WEB DEVELOPMENT',3=>'GRAPHICS DESIGN'))) ;?>
Can I create an image along with the text in each of the labels like WEB DESIGN,WEB DEVELOPMENT etc in my form
This will get the job done for you ;)
echo $this->Form->input
(
'Model.field',
array
(
'multiple' => 'checkbox',
'options' => array('1' => $this->Html->image('cake.icon.png') . 'Text beside the image', '2' => $this->Html->image('test-error-icon.png') . 'Other text beside the image'),
'escape' => FALSE
)
);

Checkbox filtering in Magento admin grid

I have a Slider model having some associated Images (models). When editing a Slider, there's a tab for its images. Now this can be modified, to select and deselect containing images. This, it seems, is done through an admin grid, having a checkbox column (the "values" key is for testing):
$this->addColumn('in_slider', array(
'header_css_class' => 'a-center',
'type' => 'checkbox',
'name' => 'in_slider',
'values' => array(1,2),
'align' => 'center',
'index' => 'slider_image_id'
));
Let's say the Slider in the above image has one image attached, and that works fine. But, when user selects "Any" and clicks "Search", all images must show, but those that are not associated should be deselected. I think this is standard behavior for such a feature.
What I don't get is the mechanism behind those two buttons: Reset Filter and Search. From what I've managed to dig up, a grid class has a getGridUrl() method which is used to refresh the grid data (via AJAX). That URL mapping to a controller.
// in grid class
public function getGridUrl()
{
return $this->getUrl('*/*/editGrid', array('_current' => true));
}
// Image controller
public function editGridAction()
{
$blockMarkup = $this->getLayout()->createBlock('module/someblock')->toHtml();
$this->getResponse()->setBody($blockMarkup);
}
But what about the "Search" button? How does that work?
How do other modules know when to show ALL entities, or searching for "Yes" or "No"?
When saving the slider, how can one grab the selected values? Working in Slider controller's saveAction I presume, but how do you get the checkbox values?
What you're looking for is a mass action. Add this function to your grid file (whatever extends Mage_Adminhtml_Block_Weidget_Grid):
protected function _prepareMassaction()
{
$this->setMassactionIdField('some_ID');
$this->getMassactionBlock()->setFormFieldName('element_name'); //html name of checkbox
$this->getMassactionBlock()->addItem('some_ID', array(
'label'=> __('Some Label'),
'url' => $this->getUrl('*/*/doSomething'), //an action defined in the controller
'selected' => 'selected',
'confirm' => __('Are you sure?')
));
return $this;
}
Here's a good blog post that helps to explain the concept:
http://inchoo.net/ecommerce/magento/how-to-add-massactions-to-magentos-grid/

Resources