Reputation: 944
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:[email protected]/joomla/administrator....) but it doesn't work. Is there anyway other way to send login credentials, or any other way to do this?
Upvotes: 6
Views: 8525
Reputation: 723
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:
Upvotes: 2
Reputation: 433
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.
Upvotes: 1
Reputation: 111
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.
Upvotes: 3