Joomla Component Creating an override for the trash button - joomla

I'm trying to override the trash button in the administrator back end in Joomla
I'm putting into the controller:
public function trash( $task = 'trash', $alt = 'trash', $check = true ){
echo "here";
exit();
}
(I've also tried it with task = remove)
But I can't get it to work. Joomla ignores this and simply deletes the field.
I've already put in a save override and save2copy but I can't figure out why this won't work. Can someone help?
thanks

I found the problem - thanks to those who've thought about it.
I'd used an auto component generator and when they had created the class they hadn't included a constructor function. So I added one and it now works fine.

Related

Laravel 5: How can a dropdown be showing the selected value that the page loads initially

I'm using Laravel and I have a dropdown which fills its options from the database on load page and another text field.
Then on the submit I validate the text field to avoid empty entries, the validation is based on the request validator from Laravel. The validation is made correctly.
The problem is that when the validation is completed (it doesn't submit because i keep the text field empty) it returns to the page, but the dropdown remains selected with the last selection by the user, but in the back(sourcecode), its selected the original value that was loaded originally.
I want that the selectedIndex is the one original from the load page, not the last one selected. I tried with javascript but I had no luck change in it since it's already as the selectedIndex, but to the user, it still showing the other option. If I refresh manually it still showing the selected one incorrectly, I need to enter the URL manually so it shows correctly.
What could be a good approach to solve this "visual" issue?
Here is the controller code
public function update($user_id,GuardarBancoRequest $request)
{
$cuenta = user::whereId($user_id)->first();
$cuenta->nombrecompleto = Input::get('completo');
$temp = Input::get('tipo');
$cuenta->tipocuenta = Input::get('tipo');
$temp1 = Input::get('banco');
if ($temp == "1") {
$cuenta->cuentaclabe = Input::get('clabehidden');
$cuenta->cuentatarjeta = Input::get('cuentahidden');
} else {
$cuenta->cuentatarjeta = Input::get('cuentahidden');
$cuenta->cuentaclabe = Input::get('clabehidden');
}
if ( $temp1 == "10") {
$cuenta->otrobanco = Input::get('otro');
$cuenta->banco = "10";
} else {
$cuenta->banco = Input::get('banco');
$cuenta->save();
}
return Redirect::route('bancos.show',array(Auth::user()->id));
}
The dropdown that I'm referring is the [tipo] one
It's hard to presume without getting a chance to look at your code, but it sounds like when you do a redirect after validation you have something like
return redirect()->back()->withInput(); which causes fields to be prepopulated with the values entered earlier on the page. Remove withInput() portion in your controller if you have this.
Otherwise please mind posting your code in addition to your question, that would be helpful. (the controller part with the redirection and the view where you have the dropdown)

Magento event name to observe

I need to add some code to Magento (1.6.2) to be executed when an orders status becomes Complete.
In our system, this happens when the order is "Shipped" - i.e. the "Ship" button is clicked, and the shipping info is saved.
I have hunted (obviously in the wrong places) to try and find what that event would be called, so that I can add an observer to watch for it firing, and then run my code.
Can anyone tell me what the name of this event would be (if it exists as an observable event) please?
Cheers!
I too find event hunting to be a bit of a dark art. In this case I would try sales_order_save_before and then check in a handler like this:
function onSalesOrderSaveBefore(Varien_Event_Observer $observer)
{
$order = $observer->getOrder();
if (($order->getData('status') == 'complete')
&& ($order->getOrigData('status') != 'complete')) {
// then order has just been completed
}
}
One possible solution is to create a custom module that override this controller
/app/code/core/Mage/Adminhtml/controllers/Sales/Order/ShipmentController.php
Then add your custom code or create you own custom event in public function saveAction()

ckeditor make dialog element readonly or disable

I need to be able to make the URL input field in the Link Dialog window readonly or disable it. The field gets populated when the user selects a file from the server.
Another user posted this link as a solution, http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.ui.dialog.uiElement.html#disable but there is no example and I can't figure out how to implement it.
In the onLoad handler of the dialog you can disable it this way:
this.getContentElement("info", "url").disable();
this is what I ended up doing. I wrote it in my js file instead of the plugin file, but I dont think that would make a difference. I am using inline ckeditor version 4.0.2
CKEDITOR.on('dialogDefinition', function(event) {
var dialogName = event.data.name;
var dialogDefinition = event.data.definition;
//some code here
if(dialogName == 'flash'){ // flash dialog box name
//some code here
dialogDefinition.onShow = function () {
this.getContentElement("info","width").disable(); // info is the name of the tab and width is the id of the element inside the tab
this.getContentElement("info","height").disable();
}
}
});
You can disable url field by just one line
CKEDITOR.dialog.getCurrent().getContentElement('info','txtUrl').disable()
I got it. I added this.getInputElement().setAttribute( 'readOnly', true ); to the onload funciton in ckeditor\plugins\links\dialogs\link.js. Before I was adding it to ckeditor\_source\plugins\links\dialogs\link.js. I'd still like an example of how to use the CKEDITOR.ui.dialog.uiElement disable feature, if anyone has one.

Auto save joomla article for client

i know its sounds a bit crazy, but so many clients have problems with not saving their article properly.
I just wanted to use a simple method to trigger the onclick of the APPLY button inside a joomla article in edit mode.
Primarily back end editing as i have a good admin template that allows me to show clients the bare bones.
I know that by clicking apply the page reloads but thats better than nothing.
How on earth do i add do this?
I was hoping something like this would work but i dont quite know how to trigger a button that seems to reside inside a toolbar function of some sort.
I have this:
<script type="text/javascript">
$(document).ready(function() {
$('??????').trigger('click');
});
</script>
What would replace the question marks?
Also i know i would need to put a timer into the jquery code but how do i get the link below to trigger?
http://mydomain.com/administrator/index.php?option=com_content&sectionid=1&task=edit&cid[]=97
In the toolbar.content.html.php file joomla has this:
class TOOLBAR_content
{
function _EDIT($edit)
{
$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
$cid = intval($cid[0]);
$text = ( $edit ? JText::_( 'Edit' ) : JText::_( 'New' ) );
JToolBarHelper::title( JText::_( 'Article' ).': <small><small>[ '. $text.' ]</small></small>', 'addedit.png' );
JToolBarHelper::preview( 'index.php?option=com_content&id='.$cid.'&tmpl=component', true );
JToolBarHelper::save();
/////////////////////////////////////
JToolBarHelper::apply(); // < // THIS IS WHAT I WANT TO TRIGGER
/////////////////////////////////////
if ( $edit ) {
// for existing articles the button is renamed `close`
JToolBarHelper::cancel( 'cancel', 'Close' );
} else {
JToolBarHelper::cancel();
}
}
...... more stuff here
}
I know this might sound crazy but wouldnt it be great if autosave could happen even without a reload, but i guess that would mean posting all the data using jquery rather than the php post and reload page method.
Anyways im not expecting a miracle here but if anyone could help that would be great.
Cheers in advance
John
PS:
i just tried something like this hoping maybe it will work but it just reloads the page:
function autosave()
{
window.location = "index.php?option=com_content&sectionid=<?php echo $_GET['sectionid'];?>&task=edit&cid[]=<?php echo $row->id;?>"
}
You won't be able to do it without forcing a reload unless you decide to re-write the whole of com_content with an ajax implementation.
Looking at the code you've posted I guessing Joomla! 1.5 - which by default has MooTools 1.12 or 1.2.5 (if you enabled the MooTools upgrade plugin in later versions of 1.5.x) - so more of a question but why not use that?
You will have to modify the admin template to embed the JS you need, 1.5 has few triggers and none that are really worth using in the admin screens (unless you're up for a fair bit of PHP coding)
Somewhere in the <head> tag of com_content's Article view you will need to add this:
<script type="text/javascript">
var interval = 30 //seconds
var timer = setTimeout(submitbutton('apply'),(interval * 1000));
}
</script>
Please note I haven't tried this just typed it straight into here.
Since you're on 1.5 have you tried the Simple Content Versioning extension - it has autosave functionality that appears to be what you want - and probably works whereas who knows with my code in #3.

Hide a group in catalog product?

Please help me if anybody know how this work can be done.
I want to hide the website tab in catalog Product, but its functionality should exist. That is, I have made all the check boxes automatically checked,so i dont want to show this tab anybody...but at the time of adding product..check boxes values would be saved.
Not exactly sure how you would do this, but basically you need to bind an Observer in the adminhtml render sequence that calls Mage_Adminhtml_Block_Widget_Tabs::removeTab($tabId) where $tabId is the Id of the websites tab (I think it's just "websites"). The trick is to find the right event to bind your Observer to, #Joseph's list of events should get you started. I would try something like adminhtml_block_html_before.
Your observer would also set the values on the product at the same time.
Good luck,
JD
In ProductController.php
Websites
*/
if (!isset($productData['website_ids'])) {
$productData['website_ids'] = array();
}
$productData['website_ids']=$this->getStoreWebsiteId(); //newly added
//newly added
public function getStoreWebsiteId(){
$selectWebsite="SELECT * from core_website WHERE website_id!=0";
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$value=$connection->fetchAll($selectWebsite);
foreach($value as $websiteDetails){
$websiteId[]=$websiteDetails['website_id'];
}
return $websiteId;
}

Resources