Automated Jobs not working
Permalink
Hello,
I have made custom job. It is use xml file. I install this job but not work. I give us the code, and please can you tel me where I made the mistake :
Thank you.
I have made custom job. It is use xml file. I install this job but not work. I give us the code, and please can you tel me where I made the mistake :
<?php namespace Application\Job; use \Job as AbstractJob; use Concrete\Core\Page\Page; class myFirstJob extends AbstractJob { /** Returns the job name. * @return string */ public function getJobName() { return t('List Portfolio'); } /** Returns the job description. * @return string */ public function getJobDescription() {
Viewing 15 lines of 51 lines. View entire code block.
Thank you.
Thank you hutman for your response.
1- Excatly I corrected the path to create my pages. $parentPage now I have just one.
2- file_get_contents return null, it's like he doesn't find the xml file and I put it in this path : /Application / jobs
Thank you for help
1- Excatly I corrected the path to create my pages. $parentPage now I have just one.
2- file_get_contents return null, it's like he doesn't find the xml file and I put it in this path : /Application / jobs
Thank you for help
Can you put the XML file somewhere else (even in the web root) and then provide the FULL path to the file_get_contents call, full path from the server root.
Is there not a function in concrete5 that allows us to know the absolute path, as Pathinfo DIRNAME.
You could leave the XML file where it is and try doing this:
$basePath = dirname(__FILE__); $filePath = $basePath . '/portfolio.xml'; if($strxml = @file_get_contents($filePath)) {
I m happy to see your code. I add this with correct path but it doesn't work and I dont have my pages :-(
Thank you.
Thank you.
If you have access to your PHP Error Logs on your website try adding this
error_log("PortfolioFilePath = $filePath \n");
I dont have access to error_log. And I have always a problem with a path.
I test my variable when the variable is empty my instruction is executed.
What can I do ?
Thank you!
I test my variable when the variable is empty my instruction is executed.
What can I do ?
Thank you!
Can you use this code to add a line to the Dashboard -> Reports -> Logs
This should show us what the $filePath variable is so we can try to figure out where it's looking for the XML file and maybe just move it there to get this working.
use Concrete\Core\Logging\GroupLogger; use Monolog\Logger; $l = new GroupLogger(LOG_TYPE_EMAILS, Logger::INFO); $l->write('filePath = '.$filePath); $l->close();
This should show us what the $filePath variable is so we can try to figure out where it's looking for the XML file and maybe just move it there to get this working.
Thank you very much Hutman, I am gradually learning about the features of concrete5. :-)
Effectively, your code gives me the exact path to my file and it's the same path of the file xml.
And when I took the code and I put in the test, it doesn't execute
I need help ! :-(
Effectively, your code gives me the exact path to my file and it's the same path of the file xml.
And when I took the code and I put in the test, it doesn't execute
$basePath = dirname(__FILE__); $filePath = $basePath . '/application/jobs/portfolio.xml'; if($strxml = @file_get_contents($filePath)) { $l = new GroupLogger(LOG_TYPE_EMAILS, Logger::INFO); $l->write('filePath = '.$filePath); $l->close(); ..... }
I need help ! :-(
Are you 100% sure that allow_url_fopen is enabled on your server? It could be that you're not allowed to use file_get_contents because of it being disabled. The good thing is that you know your XML is in the right place to be found.
There Was a path error. I corrected. It's my mistake.
Now I try to work step by step and I have the issue in this line,
The loop works well because in the log I have 3 times the execution of code because in the xml file includes 3 data.
In the dashbord I have this tree :
\1- home
1.1 - resume
1.2 - portfolio
1.3 - contact
Now I try to work step by step and I have the issue in this line,
$pt = CollectionType::getByHandle("portfolio");
The loop works well because in the log I have 3 times the execution of code because in the xml file includes 3 data.
In the dashbord I have this tree :
\1- home
1.1 - resume
1.2 - portfolio
1.3 - contact
I owe you an apology, I totally missed the big mistake here. You can't add pages to a site the same way with 5.7 as you did with 5.6. Check out the documentation here:http://documentation.concrete5.org/developers/working-with-pages/wo...
Oh my gad, I'm very very very happy, :-)
Now I can add automatically my pages.
I changed this line
by this
Thank you so much Hutman for help.
Now I can add automatically my pages.
I changed this line
CollectionType::getByHandle("portfolio");
by this
\PageType::getByHandle("portfolio");
Thank you so much Hutman for help.
1) The file_get_contents should get a full path to your files (XML and images).
2) You have defined $parentPage twice, so all your pages are going to be added under the homepage instead of the /offres page