We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24319
    • 3 Posts
    Hi!

    I am new to this forum and I hope that I’ve posted in the right category...

    I have a site in modx which displays news from different RSS sources. More exactely there is a PHP file in a folder on the same level with assets, manager etc. which is repeated with a cronjob. The PHP script reads news and puts them in the database, in modx_site_content

    As you can imagine, the newly created alias type of links for the latest news are not working, because the aliases are not listed in the cache idx file!

    How can I clear the cache from my PHP, after insterting elements into the database?

    I saw the way modx does this from inside, the same thing happens with NewsPublisher etc. but how can I do this thing from PHP files?

    Also note that I am a beginner in PHP smiley

    As I sad, my PHP file is in a folder located on the same level with manager and assets, therefore the code that I’ve tried is this:

    include_once "../manager/processors/cache_sync.class.processor.php";
    $sync = new synccache();
    $sync->setCachepath("../assets/cache/");
    $sync->setReport(false);
    $sync->emptyCache();
    


    But nothing happens! >:(

    Can someone help me on this one?

    Thank you!
      • 16034
      • 107 Posts
      Maybe it’s callable through the external MODx API?

      Read more here: http://modxcms.com/forums/index.php?topic=32070.0

      Edit: Just searched a bit for it, seems this is an addon that let’s you do just that: http://modxcms.com/ClearCache-2066.html
      (I get an error when I access that page right now, Google Cache has the content: http://74.125.77.132/search?q=cache:J6HUsdH2cuwJ:modxcms.com/ClearCache-2066.html+http://modxcms.com/ClearCache-2066.html&hl=da&ct=clnk&cd=1&gl=dk )

      It might not be the best solution, since it blurs your upgrade path a bit since it’s editing the core. I guess you could do pretty much the same with a plugin, but the external API-solution is probably a better way to do it.
        MODx snippet-glossary 101:
        Ditto = Content Lister -- Wayfinder == Menu Builder -- Jot = Comment Control
        • 24319
        • 3 Posts
        Thank you very much, Kleist!

        Having a title like "Patch for MODx that allows you to clear the cache via the command line, or an external script. ", that thing might just do the trick!

        I’ll keep talking here and say if and how I’ve done it, because others might want the same thing now or in the future.

        So I’ll try this solution and see how it works.
          • 24319
          • 3 Posts
          To me, that thing didn’t work.

          I’ve created the .docache file from php in order for it to have the good permissions, no errors occured, but when new content arrived into modx_site_content the cache was not rebuilt, therfore the links were pointing to the first page of the site.

          sad

            • 3749
            • 24,544 Posts
            Quote from: radoo at Jan 18, 2009, 07:39 AM

            To me, that thing didn’t work.

            I’ve created the .docache file from php in order for it to have the good permissions, no errors occured, but when new content arrived into modx_site_content the cache was not rebuilt, therfore the links were pointing to the first page of the site.

            sad



            Check to see if the .docache file has been deleted. It should be gone once the program has run.

              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting