Run custom php code in joomla module backend page - joomla

i am using Joomla 2.5 ,
I am working on a module .My module loads some javascripts in frontend. I want to run few php code in backend, when admin click on save button. How to do that?

You can write a plugin that uses the event trigger onBeforeSave, then when you hit the save button, the plugin is run.
You can do any validation on the data sent by post, if it fails just return false and you will return to your form.
You can see some documentation on how to do this here:
http://docs.joomla.org/Plugin/Events
http://docs.joomla.org/J2.5:Creating_a_Plugin_for_Joomla

Related

php page to be included in joomla

I have written a php page that is getting data from a database and graph it via highcharts javascript.
I would like now to be able to put that in joomla and then use the username from joomla to graph the specific data from that user.
How can I do that?
Thanks for your help,
John.
You should use an iFrame Wrapper menu item whenever you want to include a page that isn't part of your Joomla website.

Cart functionality in Magento from scratch

I'm fairly new to Magento and am setting up a new theme from scratch. I'm not using any of the standard Magento JS files until now and I've included jQuery and a js file for custom scripts.
Now I'm looking into recreating the Add To Cart functionality but standard wise this seems to call some js function which I do not have declared now (lacking the Magento JS files). I'd like to set it up on my own with an ordinary form submit.
Can anyone give me an example of how to execute the Add To Cart command for the product I'm currently viewing? Without the necessity of standard Magento JS files?
What Magento do for add to cart is it calls productAddToCartForm.submit function of javascript to validate all required field and if true then it submit product form.
So you can call your javascript method for form submit and add to cart.
Add to cart button comes from this file, so you can change onclick event here.
app\design\frontend\base\default\template\catalog\product\view\addtocart.phtml

Modify component output using module......Joomla 3.0

I am a new developer in joomla.
I just want to integrate joomla component to custom module.When a user install module then output of related component must be change as per module file automatically .
I want to use filters with Jreviews_geomap_addon.So create a module to use filter icons into geomap...
Thanks
The module should have a form or link that submits or changes the URL when clicking on the links. You can then read the url parameters using:
$var_name = JFactory::getApplication()->input->get('var_name');
You can then use the $var_name to change what data is displayed by your component.

Database in Joomla?

We put the program on the joomla article and we have the config.php located in the directory/images/php/config.php
I have 2 php pages that i want to include in joomla (pond.php and p_pond.php)
pond.php has a submit button, but when the submit button is clicked, it does not connect to database and it does not go to p_pond.php page
How can we connect to the database when the page is loaded?
Use JUMI component to use your personal PHP page and look at this page for database connection
Joomla works on MVC so you should follow the MVC rule.
For displaying a page you need to make a component.
read joomla docs to make component
here is the link http://docs.joomla.org/Developing_a_Model-View-Controller_Component/1.5/Introduction

how to run an admin task in joomla with a cron job?

I wrote a custom component in Joomla! that pulls in content from an XML feed and stores it in the Joomla database. I want the admin URL (/administrator/index?option=com_mycomp) to run via cron once every night to run the component. I can't figure out how to make this work, though, since the component is an administrator task and you have to be logged in to run it.
How do I get by this? I tried including my user/pw in the url (http:admin:password#www.mysite.com/joomla/administrator....) but it doesn't work. Is there anyway other way to send login credentials, or any other way to do this?
I know this thread is very old, but here's how I handled a similar task.
The "trick" is to take the custom PHP code you have created, and embed it into an article within your Joomla website.
I did this by using the JUMI extension, that allows custom PHP code to be stored within the Joomla repository and embedded, as required, within an article.
Then, create a CRON task that will activate the appropriate URL for the page containing the code you want to run.
Just put your script in the administrator directory of the component like
/administrator/components/com_yourcomponent/cron.yourcomponent.php
This is how FeedGator handles cron tasks [Sounds very similar to what you're trying to do.] ... you can also write a frontend controller in your component per one of the comments
========== [Update] ============
I created this ultra-simple installable component that could also be used for this purpose. It allows for a frontend menu item to be assigned to a php page (including the route as suggested). So you:
install the component
create new menu item, (may want to use a 'hidden' menu) select the 'show' view option and enter the script to run via cron in 'file to include' like path/yourcron.php
call the 'page' in your cron or test using: yourjoomlasite.com/index.php?option=com_show or yourjoomlasite.com/your-menu-alias
Mostly corn urls works from front-end even if your component deals with administrator only in Joomla.
So whatever your code in admin cron get it to front-end & so that your cronurl becomes like index.php?option=com_yourcomponent&task=cronjob.
Use this url to set cron using cPanel.
However this solution doesn't need to see whether admin is logged or not.

Resources