We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24418
    • 9 Posts
    I’ve stumbled upon an interesting problem.

    I need to change some constant phrases in the front-end, such as "Bot-patrol", "Log-in Details", etc. I can not find them (using search) anywhere (including lang and snippet files)except sitecache.idx.php, but there is no point in altering them there for obvious reason: after the first update of the cache file all changes disappear. So where should I search for the phrases to change?

    Thanks.
      And each small candle lights a corner of the dark
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      These must be from custom snippets or plugins; they certainly aren’t part of a default MODx installation. That cache file does maintain a copy of all snippet, chunk, template and plugin code, so if any of these have hard-coded text it will show up in the cache file.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 24418
        • 9 Posts
        Thanks for reply!

        What do you mean exactly by saying "hard-coded", where is that code? Should I check the databases? Cause I can not fine the text in *.php or *.inc files of custom resources.
          And each small candle lights a corner of the dark
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          check the actual snippet/chunk/plugin code (Elements -> Manage Elements). If the text is in the cache file, that means it’s in the database. The cache file stores the code so that MODx can take it from cache rather than making more database queries. It’s a trade-off; bloating the cache file vs. multiple database queries. To a point it’s a time/server load benefit.

          This is why even in simple custom snippets it’s a bad idea to hard-code output text; it should always be possible to edit it in a config file, a tpl chunk or language file for easy management. It takes a few more minutes to develop, but saves a lot of time and grief later.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 24418
            • 9 Posts
            Thnx a lot, I think I’ve found the text in modx_site_htmlsnippets table. Now the problem is to edit it with phpMyAdmin. It seems that we can only delete the appropriate record and then replace it with the edited one. Or may be you can recommend some GUI tool to edit MySQL db? As far as I remember about 5 years ago I used something like MySQLLight for the purpose but unfortunately now can’t find it...
              And each small candle lights a corner of the dark
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Those are chunks. In your MODx Manager go to Elements -> Manage Elements and the Chunks tab, and open the chunk for editing.

              And you can in fact edit the database fields directly with phpMyAdmin as each field has icons for editing (a little pencil), although it’s not recommended in most cases as there are a few additions such as escaping \ for quotes or \r\n newline characters added and removed during the database processing. Direct database manipulation is best reserved for emergency situations.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 24418
                • 9 Posts
                Great, thanks! It’s mainly my fault, I’ve got used to work with files and not with back-end, but MODx is great laugh Nevertheless, it was important to learn about sitecache.idx.php. Thanks again!
                  And each small candle lights a corner of the dark
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You can work with files by using a snippet that has a parameter for the file, then simply uses an include directive to include the file specified. This will not only keep the cache much smaller (since only the snippet call will appear as the chunk’s content) but allow you to continue working with files if that is what makes you more comfortable. This works for templates as well, and of course snippets and plugins can always just have a one-liner including an external file.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org