I'm trying to figure out how to run a function/script as soon as an item is saved in joomla 2.5. Joomla's MVC structure is still rather complicated to me so I'm pulling my hair here trying to find out where this save event is triggered. Also I want to keep the code neat so I'm asking here for help.
Basically I want to run my own function (let's say emailUser() ) as soon as an item is saved in joomla. Currently there is no way for me to do "other stuff" when the save event is triggered.
I'm using a custom component generated with the component creator here:
http://www.notwebdesign.com/joomla-component-creator/
I heard that plugins are the solution, but I can't find any documentation on the save events and how to use a plugin to do this. Joomla's help forums aren't helping either. So basically I need a push in the right direction.
EDIT:
I've seem to found the toolbar which creates the save button, but that means that it's saved through the internal workings of joomla. It's in the view.html.php file. Any way of tapping into that with a custom function?
Inside the controller of the component (administrator/components),how about redefining the save event to be something like this:
$save =& JToolBarHelper::save('clientscan.save', 'JTOOLBAR_SAVE');
if($save)
{
JFactory::getMailer();
//emailing goes here..
}
After save would say use a postSaveHook in your controller.
Related
I've found a number of plugins for wordpress that add a link to the table in the backend to clone or duplicate a post or page (Duplicate Post, Clone Post, and Post Duplicator). This is nice, but I'm building a bit of an app on wordpress where I'm using a custom post type as an entry and would like to be able to quickly copy an entry with a link from the frontend of the site (similar to how edit_post_link works but without jumping into the backend).
I'm using Gravity Forms for the create and edit functionality for entries on the frontend, but I can't quite figure out the best approach for a secure way to submit a request, execute the clone query, and the return to the same page I was on before (i.e. not jumping into the backend). Gravity Forms Post Updates plugin does something similar with a do_action call to generate a link. I've looked through this function and generally get what's happening, but I'm not sure if I need all of the extra plugin class structure.
I was hoping to find an example of a function that could create a secure url with a nonce and then another function we validate the url and execute the query and return to the previous page. Is this the right way to go or am I barking up the wrong tree? If so, any code samples or examples that might be able to help get me started?
Much appreciated!
I found this post (http://rudrastyh.com/wordpress/duplicate-post.html) and was able to figure out what I needed to. Instead of adding a filter to include the link in the backend, I instead created an action that can be called with do_action and generates the link. I also have a page and page template that is solely for executing the call and then redirecting back to the referring url.
On one of the sites i need to do some changes on for a client i am having trouble finding something.
On the standard Joomla 3 registration system a custom field was added to the form, but that form does not email to the admin when someone registers, please can someone point me in the correct direction on where i can make that field be sent in the email.
I have looks on quite a few pages on the net but have not come right with any of the answers that i found. I have also tried going to most of the php files to see if i cant find something but i am not having much luck.
Unfortunately that email is hard coded; it is really a legacy from Joomla 1.0. What you would probably want to do is turn off the core notification system and instead use a plugin that would be triggered with the onUserAfterSave event and use similar code to what is in the core. You will find that in the activate($token) method in the frontend registration model for com_users.
The plugins/user/joomla plugin gives an example of how to build an email, bit in your case you would want to build it when the user is created in the site application (isSite() == true). You can also look at the contactcreator plugin in the same folder; it also uses the onUserAfterSave event.
I'm new to joomla! extension development, and I'm developing a simple component,the idea of my component is to insert a couple of data into database. In the admin when people click on the new button it should enable them to insert values according to the form I created. Here is my problem when I click on the new button it show's me this error:
JForm::getInstance could not load file
So far i have created all the basic MVC model that the joomla! interface needs. Need help.
Thank you.(I'm using Joomla! version 3.0)
That error is because joomla is not loading your form correctly. Can't say anything else without looking at the code, sorry.
If you want to see how a component works with a clean, functional written code, check http://component-creator.com. It creates a complete component with CRUD functions in 5-10 mins.
Regards,
Andrés
Couple of weeks ago I started working with ZF2, with a new project. I need some guidance about how to implement a
feature. I want to implement a "Like" button (E.g FB like button) this button will be attach to almost all the components
like uploaded Photos, Videos, Etc.., Honestly I don't have a much idea how this should be implemented with ZF2. Can someone
put me to the correct track. I don't need to know how to code it but just need to know what path should I take what is the best way ?
Thanks,
Well, since a Facebook Button is nothing but a little Javascript-Snippet with a URL attached, all you'd have to do is to build a ViewHelper that get's the current Route or URL injected. That ViewHelper would then print out the JS Snippet and create the specific like button.
The JavaScript that is required for that would be injected using the head*()-viewHelpers.
No need to make it any more complex than that. Furthermore i see no easier solution than this, as the position of the button and the displayStatus would be different on pretty much each page.
I'm using Jumi to echo php code and then showing that in a Joomla Article, and everythings working fine. Now I want to do this:
The output is basically a list from a database like this:
Name Price Type
A 1 T1
B 2 T2
In this list I want to include links to only show items of the same type, so "T1" would like to a page only showing things of type T1. So I thought I would do this by making a new page that takes a type and then get all the items of that type from the database. Without Joomla this wouldv'e been a piece of cake, with Joomla I'm not quite sure where to begin.
How should the a href=... tags in the html code printed by my php script look?
Is my basic structure still correct, and if so, how do I make Joomla open the new page in the normal frame and not replace the whole Joomla page. some kind of target-frame attribute?
EDIT:
I know I should be using a component instead, however I just need to get this working before going on vacation in three days. I will do it properly when I get back.
I don't mind if the entire page reloads, what I do need is the Joomla menu, header-banner and other things around the page to be loaded as well. If I just use a href=mypage.php I assume the header and everything around it will disappear.
I think you are going about this all wrong. You shouldn't be using Jumi to run php in your articles. You should design a component. Although this will take a tiny bit longer to setup initially it will save you time in the long run and prove to be much more flexible than using Jumi in a single article. Have a look here on how to create a Joomla component - http://www.joomladevuser.com/tutorials/components.
a href= tags should not be any different from any other html you have ever used.
E.g. echo 'link';
To make just the frame/div/table/etc reload rather than the entire page you will need to implement some AJAX. I have answered a question on how to do this with Joomla components before, see here: how to use Jquery AJAX in Joomla Components?