Adding Editor into a component - joomla

My task is to get/make WYSIWYG editor. I read that u can get it quite simple:
$editor = JFactory::getEditor();
$params = array( 'smilies'=> '1' ,
'style' => '1' ,
'layer' => '1' ,
'table' => '1' ,
'clear_entities'=>'1'
);
echo $editor->display( 'desc', '', '400', '400', '20', '20', false, null, null, null, $params);
Problem is,
How can I remove the buttons I don't want to see?
How can I place it (for example in second field when I've 4 of them?)
Right now, all that code is view.example.php file.

In Joomla form fields you can easily set this parameters
To remove smilies and table button
Check this https://docs.joomla.org/Editor_form_field_type.
To achieve the same in legacy way you can do as explained here https://docs.joomla.org/API16:JEditor/display (J16 API)
Its quite simple. If you go through this code
$params = array( 'smilies'=> '1' ,
'style' => '1' ,
'layer' => '1' ,
'table' => '1' ,
'clear_entities'=>'1'
); //You are enabling with '1'
What you are trying to do is enabling smilies, style, layer, table and clear_entities. If you want to disable any of these simply change 1 to 0. so 'table' => '0' will remove table button.
If you are using Tinymce editor then you have the option to enable disable buttons in the extended mode.
You can even authorise buttons for different users at different levels.
You need to find the Plugin Editor - TinyMCE. Enable the extended mode and on the Advanced tab you can play with buttons.
Check this image

Related

Laravel validation in combination of two array data

How could I validate it from request file?
I want to check distinct combining floor_id and material_id,
having a floor id can not have same material_id twice or more
From a form data i get this kind of output
project_id => 5,
date => 12-15-2022,
floor_id => array(
0=> 1,
1=> 5,
2=> 12
),
material_id => array(
0=>15,
1=>2,
2=>20
),
quantity => array(
0=>2500,
1=>3500,
2=>6522
)
How could I validate it from request file
may be you can use validation distinct
https://laravel.com/docs/9.x/validation#rule-distinct
You can write a custom validation rule to serve your purpose.
Here you will get some idea https://laravel.com/docs/9.x/validation#custom-validation-rules

Magento both AND and OR conditions in a collection

I want make a query which looks like below to filter some products (using attributes) from product collection.
SELECT <attributes>
FROM <tables & joins>
WHERE (<some AND conditions>) OR (<some AND conditions>)
WHERE condition should filter products that match either first set of AND conditions or second set of AND conditions.
Problem is I can't find a way to add an OR condition in between multiple AND conditions.
Can anyone help me to code above where condition using Magento addAttributeToFilter()? or any other functions?
If i'm understanding you correctly I think you need to do some variation of this:
->addAttributeToFilter(...filter here...)
->addAttributeToFilter(array(
array(
'attribute' => 'special_to_date',
'date' => true,
'from' => $dateTomorrow
),
array(
'attribute' => 'special_to_date',
'null' => 1
)
));
which would be:
...filter here... AND (special_to_date >= '2012-07-03' OR special_to_date IS NULL)...

how to update Cart Options in Codeigniter?

Through Documents provided by Codeigniter Its Cart Library doesnt Update its options We can add the Options like that
$data = array(
array(
'id' => 'sku_123ABC',
'qty' => 1,
'price' => 39.95,
'name' => 'T-Shirt',
'options' => array('Size' => 'L', 'Color' => 'Red')
)
);
$this->cart->insert($data);
Is there any other way or any tutorial to learn how we can update options of Cart just like
$qid = $this->input->post("qid");
$pairs = $this->input->post("pairs");
$males = $this->input->post("males");
$females = $this->input->post("females");
$data = array(
array(
'rowid' => $qid,
'qty' => 1,
'options' => array('pairs' => $pairs, 'males' => $males, 'females' => $females))
);
$this->cart->update($data);
I have searched it but seems no one has made any fix for it?
Though I have not found any solution therefore I am using simple solution and that is just rest the item in cart and adding new item with same id and updated option values. Its not great trick though but it is just working for me.
I am fallen yesterday like this kind of problem then i create Extending / Override update function. Here how to Extending Native library Link : Create CI Library
Here is my modified code in Github Link
I hope it will help someone and also can modify as their need.
No it did not work for me.. but there is no any errors, I check the array within the _update function as well,
Array
(
[id] => 177
[rowid] => 66bd8895e10f189f62bf3a65ada83630
[qty] => 1
[options] => Array
(
[vat] => 0
[discount] => 0
)
)
I know i'ts just too late but I want to share my solution:
I just got the the options in an array and updated it as I wanted and then update the entire options field in the cart with the array content.
Hope this help somebody.
Sorry for the english.
The way I tried was a bit difficult but it works. You can’t just update a single option value. To update you have to pass all the existing values to all the option values with the value you want to update as well.
If you want to update your Size option
$data = array(
‘rowid’ => $yourRowIdHere,
‘options’ => array ( ‘color’ => $yourExistingValue, ‘length’ => $yourExistingValue, ‘size’ => $newUpdatedValue)
));
$this->cart->update($data);
Give it a try :)

Order by title without taking into account 'the' in Wordpress (wp_query)

I currently have episodes from a TV Show that feature bands playing, so for example I have:
Moby
The Dandy Warhols
The Kooks
My wp_query looks like this:
$loop = new WP_Query(array('post_type' => 'episodio', 'cat' => '9', 'posts_per_page' => 90, 'orderby' => 'title','order' => 'ASC' ));
But I want to order them like this, alphabetically, without taking into account 'the':
The Dandy Warhols
The Kooks
Moby
There are a lot of records in the database, so it's not very practical and/or efficient to get everything into an array, remove 'the', order again and then going through the array to display the data.
Is this possible in WP? Maybe through a filter?
Thanks a lot in advance! :)
$loop = new WP_Query(array('post_type' => 'episodio', 'cat' => '9', 'posts_per_page' => 90, 'orderby' => 'title','order' => 'DESC' ));
you will get result post title descending of category 9.

Is it possible to customise drupal node reference and pass your search and a argument from another field

I'm trying to create a bespoke form in drupal, with a node reference field.
I'd like to add a little extra functionality to the node reference auto complete. I've created a view, that contains an argument. I'd like to be able to pass that argument from a drop down as well as the typed text into the autocomplete script.
Does anyone know how I'd start this off.
/* FIELD 1 - the drop down */
$sql = "SELECT nid, title FROM node where type='resourcetype' AND status =1 order by title
";
$result = db_query($sql);
$counter = 0 ;
$options = array();
while ($data = db_fetch_array($result)) {
// krumo ($data);
$options[$data[nid] ] = $data[title] ;
if ($counter ==0 ) {$df = $data[nid]; }
$counter ++;
}
/* FIELD 2 - the node reference field */
$form['sor']['type'] = array(
'#type' => 'select',
'#title' => t('Resource type'),
'#required' =>TRUE,
'#options' => $options,
) ;
$form['sor']['field_asor_sors'] = array(
'#type' => 'textfield',
'#title' => t('Add a SOR item to this job'),
'#autocomplete_path' => 'nodereference/autocomplete/field_asor_sors',
'#element_validate' => array('myelement_validate_is_valid_noderef'),
'#required' =>TRUE,
);
Many Thanks
Matt
AFAIK there is no easy way to do this.
I wanted to do something similar a while ago (using different arguments based on node context), but refrained from doing it, since it would've needed some significant changes of the autocomplete callback logic. You'd need to change several nodereference functions to add support for passing an argument to the initial callback nodereference_autocomplete(), passing it on from there to _nodereference_potential_references(), and finally to _nodereference_potential_references_views(), while ensuring that the changes don't break anything else.
If you want to try nonetheless, you should take a look at the patches in this thread, as they also want to do something like that and might contain some useful hints/examples.
A potentially easier alternative might be to exchange the #autocomplete_path callback of the nodereference field with your own custom version that would generate the result, while adding js logic to your dropdown to add an additional argument to that path when the selection changes.
If you go into the nodereference field configuration form, and scroll all the way to the bottom, there's a fieldset (which may be collapsed) that is titled 'Advanced - Nodes that can be referenced (View)'. You can use this to select a view and have that view be the source of the nodereference choices without writing any new code.

Resources