Execute a job to add new page

Permalink 1 user found helpful
Hello all,

I want practice "Adding a New Page Programmatically", but my job can't create my test page.

<?php
namespace Application\Job;
use \Job as AbstractJob;
class AddPortfolio extends AbstractJob {
   /** Returns the job name.
   * @return string
   */
   public function getJobName() {
      return t('add page Portfolio');
   }
   /** Returns the job description.
   * @return string
   */
   public function getJobDescription() {
      return t('Load my portfolio');


Thank you for help.

 
carlremy replied on at Permalink Reply
carlremy
There is no method Cache::disableLocalCache()

Also, you need to add
use Concrete\Core\Cache\Cache;
at the top.
belhmidi replied on at Permalink Reply
Thanks a lot. I add it but doesn't work :-(

namespace Application\Job;
use \Job as AbstractJob;
use Concrete\Core\Cache\Cache;
/*here my code*/
carlremy replied on at Permalink Reply
carlremy
Did you make sure to remove
Cache::disableLocalCache()
belhmidi replied on at Permalink Reply
Yes. and doesn't work.
namespace Application\Job;
use \Job as AbstractJob;
use Concrete\Core\Cache\Cache;
class AddPortfolio extends AbstractJob {
   /** Returns the job name.
   * @return string
   */
   public function getJobName() {
      return t('add page Portfolio');
   }
   /** Returns the job description.
   * @return string
   */
   public function getJobDescription() {
      return t('Load my portfolio');
carlremy replied on at Permalink Reply
carlremy
EDIT: Try changing
Cache::disableCache();
to
Cache::disableAll();


http://documentation.concrete5.org/api/class-Concrete.Core.Cache.Ca...

What happens when you run the job? Does it throb forever? Does it complete and display a message when it's done? Which version of the 5.7 branch are you using?

I figured out what was wrong by running `tail -f /path/to/error-log` on my server.
Could you try that as well?
belhmidi replied on at Permalink Best Answer Reply
Thank you very much for your support. when I change DisableCach() to disableAll(), my job run correctly. (I'm very happy)

I'm a beginner developper for concrete5, and now I use last version 5.7.5.6

presently I try to develop short code in order to understand concrete5. but when I have error, the system doesn't display it, even if I activate it in debugging setting, its like I dont have error.

My goal is read xml file and create a new pages :-)

I will continue to evolve my code and coming back to you
belhmidi replied on at Permalink Reply
I'm back,

I want to read the xml file and create a new page but my code can't create it. I think I have probleme with namespace or other.

add_portfolio.php
<?php
namespace Application\Job;
use \Job as AbstractJob;
use Concrete\Core\Cache\Cache;
use URLify;
class AddPortfolio extends AbstractJob {
   /** Returns the job name.
   * @return string
   */
   public function getJobName() {
      return t('add page Portfolio v2');
   }
   /** Returns the job description.
   * @return string
   */


portfolio.xml
<?xml version="1.0" encoding="UTF-8"?>
   <ERRORCODE>0</ERRORCODE>  
   <RESULTSET FOUND="2">      
      <ROW RECORDID="1">
         <COL><DATA>1</DATA></COL>
         <COL><DATA>Markdown</DATA></COL>
         <COL><DATA>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla consectetur enim eget eros accumsan, </DATA></COL>
         <COL><DATA>http://www.test.com</DATA></COL>      
      </ROW>
      <ROW RECORDID="2">
         <COL><DATA>2</DATA></COL>
         <COL><DATA>Ticks</DATA></COL>
         <COL><DATA>Curabitur nec convallis enim. Proin maximus tortor vitae sodales auctor. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla in dui tortor. </DATA></COL>
         <COL><DATA>http://www.other-test.com</DATA></COL>        
      </ROW>


Thanks for help.