We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28033
    • 925 Posts
    I have all of the spells and attacks for a game inside chunks, since I have it set up so I can check them off in the TV listing for a page and include them anywhere I need them (walkthrough, etc.).

    Now, in this one game, there are skills that change specific spells into new ones. I have a parameter called &skill=`skillgoeshere` that notes the skills needed for the spell to be changed. On the skills page, I want to list what spells they would change.

    I know in PHP I can search text using regular expressions/etc., but I would need to do the following...

    1) Get access to the chunks table in the database.
    2) Find a specific category (like x360_vesperiaBaseArtes), and grab it’s ID so I can search the chunks table for anything match that ID.
    3) Once I find a chunk that matches the category ID, search the text inside that chunk for X skill.
    4) If it finds X skill, I would the name of the spell to an array.
    5) Once I look through everything, I print out the names from the array.

    Basically I don’t know how to obtain access to the chunks table and grab the ID from it. I learned enough PHP where I can do the text searching and the array stuff, but I don’t know how to access the database.

    Any help is appreciated. smiley
      My Snippets
      -> PopUpChunk v1.0
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      The chunks table is called "htmlsnippets".

      Not sure what you mean by "id"; if you need to get access to a chunk by its name, you can use $modx->getChunk(’chunkname’) to get the contents of the given chunk.
        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
        • 28033
        • 925 Posts
        Quote from: sottwell at May 06, 2009, 10:08 AM

        Not sure what you mean by "id"; if you need to get access to a chunk by its name, you can use $modx->getChunk(’chunkname’) to get the contents of the given chunk.

        Basically I need to grab chunks from a specific category, which I think is a specific ID (i.e. number). That way I’m not search through the 1000+ chunks I have.
          My Snippets
          -> PopUpChunk v1.0
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah, yes. Now that is an interesting idea! I’ve often thought that those categories might have more uses than just organizing the display in Manager!
            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
            • 10449
            • 956 Posts
            They’re stored here:
            Table categories: "Categories to be used snippets,tv,chunks, etc"

            And referenced here:
            Table site_htmlsnippets (chunks): category (INT)

            There’s a tutorial on the Wiki, maybe you can use this as inspiration: http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
              • 28033
              • 925 Posts
              Quote from: ganeshXL at May 06, 2009, 11:38 AM
              There’s a tutorial on the Wiki, maybe you can use this as inspiration: http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks

              Ooh, looks like that code might help. *bookmarks* Thanks. smiley

              I’ll post the code back to the community once I’m finished coding it.
                My Snippets
                -> PopUpChunk v1.0