We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 28672
    • 24 Posts
    I have searched in MODx website and the forum but not quite found what I am looking for.

    I need a function that lists about 400 stores and their locations. You should be able to choose city from a list, maybe a dropdown menu, or search by city and get up stores in the area chosen/searched for.

    I have an excel document with stores and cities in various fields and want to import this (csv?) somehow, somewhere. Can I have the this data as a list somewhere in modx, or in the database and read it from there or do I really have to make documents in modx for each and every store. That will be a lot of documents in modx...

    Does anyone know if there is some ready-made solution for this, or how I can resolve this?

    Many thanx!

    /Tomas
      • 3749
      • 24,544 Posts
      It’s relatively easy to export the Excel document to CSV (SQL might be better if that’s an option) and then import it into the MODx DB using PhpMyAdmin’s Import function (I would back up the MODx DB first, just in case, by using Export in PhpMyAdmin to save it to an .SQL file).

      Once the data is in the MODx DB, I think you’ll need a custom snippet to interact with it.

      If you’re using MODx Revolution, you can see the storefinder tutorial, which sounds pretty close to what you want:

      http://svn.modxcms.com/docs/display/revolution/Using+Custom+Database+Tables+in+your+3rd+Party+Components
        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
        • 28672
        • 24 Posts
        Thank’s BobRay. Yes, storefinder is very much what I’m looking for. But unfortunatley I’m running Evolution. It’s a client site so I don’t want to install the Revolution Beta version. I’m not a programmer and would appriciate some tips on how I can code the snippet to interact with the DB.

        Again, thank’s a lot for your help!
          • 5340
          • 1,624 Posts
          Maybe you can get away with using a javascript solution like this

          http://gregweber.info/projects/demo/flavorzoom.html
          or
          http://rikrikrik.com/jquery/quicksearch/

          So the only piece of php you have to build is a snippet that shows all the entries.

          1. Import the csv using something like phpMyAdmin
          2. create a snippet that displays all the entries. Use http://wiki.modxcms.com/index.php/API:DBAPI:getHTMLGrid
          3. Put the snippet in your search page
          4. Apply the javascript plugin

          Good luck
            • 28672
            • 24 Posts
            Hi, and thanx cipa for your soulution.

            I have now printed the list via a snippet I found here on the forum, and it works. But when I got that to work the encoding for the Wayfinder menu (only on the same page I got the list) stopped working. So now my swedish letters in the menu looks like this: Ö Ä

            First I didn’t got the swedish letters to work in the list. But then I found that it might work with mysql_query("SET NAMES utf8"); and it did. But that’s when the menu crached.

            Here is the snippet:

            <?php
            mysql_query("SET NAMES utf8");
            mysql_query("SET CHARACTER_SET utf8");
            $output = '';//create variable for holding the output
            $sql = $modx->db->query( 'SELECT * FROM `modx_kunder`');//define the DB query, in this case the table is named 'tblprojects', add WHERE AND etc. as needed
            $resultArray = $modx->db->makeArray( $sql );//put it into an array
            foreach($resultArray as $item)//go through each record in the array
            {//start looping through the data array
            $params['stores']=$item['Stores'];//set the placeholders, the $params sets the name of the placeholder, the $item is the column name from the DB table
            $params['adress']=$item['Adress'];
            $params['postnr']=$item['Postnr'];
            $params['ort']=$item['Ort'];
            $params['telefon']=$item['Telefon'];
            $output.=$modx->parseChunk('StoresTpl', $params, '[+', '+]');//define the chunk name and process the content, here it's ProjectTpl which has the placeholders for the data
            }//finish looping through the data array
            return $output;//now return the output from the processed chunk
            ?>




            Encoding:
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />



            Database:
            MySQL charset: UTF-8 Unicode (utf8)
            MySQL connection collation: utf_swedish_ci (same at the tables)


            Anyone got an idé of what’t wrong?
            I am so greatful for your help, THANX!

              • 28672
              • 24 Posts
              Is there anyone who have an suggestion how I can solve my Encoding problem?
                • 5340
                • 1,624 Posts
                Not sure what is happening but I would try to

                0. Backup your db
                1. go to php my admin if you have one and set the database collation to utf8_swedish_ci

                  • 28672
                  • 24 Posts
                  I have done that and it still doesnt work. Start to get frustrated...
                    • 19889
                    • 616 Posts
                    I had an encoding problem with Reflect - the Ditto archive script - putting this setlocale(LC_TIME, ’de_DE.UTF8’, ’de.UTF8’, ’de_DE.UTF-8’, ’de.UTF-8’);
                    into the config file solved the encoding issues - maybe it helps.
                      • 28672
                      • 24 Posts
                      Hi there mmjaeger!
                      You mean put the setlocale in a wayfinder config file. In which one, there are several config files, default.config.php? Well I’ve tried that and it didn’t work anyway... embarrassed

                      It’s so anoying that I got the encoding to work in the outprint of the data but something messing up the wayfinder code.