We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12793
    • 293 Posts
    Quote from: sharkbait at Jan 24, 2010, 04:46 PM

    *edit: quick demo: http://kunane.yourweb.de/dbedit.html

    Greeeeeeeeat I like it!!!

    Could you send me the source code of this example??

    Thanks thanks thanks
      • 26931
      • 2,314 Posts
      Could you send me the source code of this example??
      here you go smiley

      following this thread:
      http://modxcms.com/forums/index.php/topic,44506

      i suggested the "Module Maker" which you can download here:
      http://modx.cmsthingies.com/module_maker.html
      support thread: http://modxcms.com/forums/index.php/topic,39174.0.html

      but unfortunately the module installation didn’t work and threw an error. i’m sure there’s an easy fix for this, but the creater of Module Maker hasn’t answered yet. it’s a great addon for sure. In the Module Maker documentation is an example db table that i created via phpMyAdmin in my MODx db. i used this code:

      1. create the db table
      --------------------------------
      CREATE TABLE `test_address` (
      `id` int(11) NOT NULL auto_increment,
      `forename` varchar(255) NOT NULL,
      `surname` varchar(255) NOT NULL,
      `address` varchar(255) NOT NULL,
      `postcode` varchar(25) NOT NULL,
      `town` varchar(255) NOT NULL,
      `county` varchar(255) NOT NULL,
      `coordinates` varchar(255) NOT NULL,
      `telephone_number` varchar(25) NOT NULL,
      `website` varchar(255) NOT NULL,
      `email_address` varchar(255) NOT NULL,
      PRIMARY KEY  (`id`)
      );


      bunk58 suggested then to either use SQLBuddy or the "dbEdit" module which you find here: http://modxcms.com/forums/index.php/topic,32720.msg199092.html


      2. install the module
      --------------------------------
      i installed Cipa’s version from here: http://modxcms.com/forums/index.php/topic,32720.msg256471.html#msg256471
      -> download: http://modxrules.com/assets/files/downloads/dbedit.zip
      ( but you should probably go with ncrosslands version further down that thread: http://modxcms.com/forums/index.php?action=dlattach;topic=32720.0;attach=10685 )

      the dbEdit module is setup to only use and show tables that don’t have your MODx table prefix (usually modx_ ). because i didn’t manage to configure dbEdit to show my non MODx prefix tables, i made those to changes in index.php of the module ( wouldn’t recommend it though, because a client can easily mess with the db ):
      http://modxcms.com/forums/index.php/topic,32720.msg216325.html#msg216325
      http://modxcms.com/forums/index.php/topic,32720.msg216386.html#msg216386

      module installation:
      ----------------
      copy your "dbedit" into assets/modules

      ..then "Manage Modules" -> "New Module" -> name: dbedit -> copy & paste the content of "dbedit.module.php.txt" into the textarea and under "Configuration" + c&p:
      &mod_path=Module path;string;assets/modules/dbedit/ &dbedit_date_format=Date Format (use d,D,m,M,F,n,y,Y as in php date() with simple separator);string;d F Y

      in the "Module configuration" field ... now "save" and go back to "Manage Modules" where you see the "dbedit" module and an icon to its left side. click on that and choose "Run Module". after that you might need to clear your cache or log out and in to see the actual module.

      now you can choose whatever table is in your MODx db.
      Once you selected your "test_address" table by clicking "Add New Table" in the module interface, you’ll be able to configure everything you need and should see a similar interface like on the screenshots from my demo site.


      3. install the loopDbChunk Snippet
      --------------------------------
      to display the records on your website you need to install the loopDbChunk Snippet from here: http://modxcms.com/forums/index.php/topic,14654.0.html

      call it like this on your site:
      [!loopDbChunk? &tableName=`test_address` &numLinks=`2` &orderby=`town desc` &chunkName=`address` &perPage=`2` &missingValTxt=`--`!]


      the Chunk "address" is (it’s all messy - ignore the inline styles - needed a quick demo smiley ) :
      <div class="product_block" style="float:left;margin: 0px 20px 20px 0px;background-color: #ada86f;border: 1px solid #666;padding: 5px;">
      <div  class="product_desc">
      first name: <span class="addresscolor">[+forename+]</span><br/>
      surname: <span class="addresscolor">[+surname+]</span><br/>
      address: <span class="addresscolor">[+address+]</span><br/>
      postcode: <span class="addresscolor">[+postcode+]</span><br/>
      town: <span class="addresscolor">[+town+]</span><br/>
      coordinates: <span class="addresscolor">[+coordinates+]</span><br/>
      telephone: <span class="addresscolor">[+telephone_number+]</span><br/>
      website: <span class="addresscolor">[+website+]</span><br/>
      email: <span class="addresscolor">[+email_address+]</span><br/>
      </div>
      <div class="product_details">
      <div style="margin-top: 10px;"><img style="border: 1px solid #fff;"  src="[+county+]" width="200px" height="200px;"></img></div>
      </div>
      </div>


      now you can add records and the result should look like on my demo site.

      hope this make sense. if you’re running into problems give me a shout smiley
        • 12793
        • 293 Posts
        Thanks for help me!!
          • 12793
          • 293 Posts
          Hi Sharkbait, thanks for help me

          I’ve installed all but I’ve a problem with snippet creation (final step of your post), Where I’ve to insert these:

          [!loopDbChunk? &tableName=`test_address` &numLinks=`2` &orderby=`town desc` &chunkName=`address` &perPage=`2` &missingValTxt=`--`!]

          and

          <div class="product_block" style="float:left;margin: 0px 20px 20px 0px;background-color: #ada86f;border: 1px solid #666;padding: 5px;">
          <div class="product_desc">
          first name: <span class="addresscolor">[+forename+]</span>

          surname: <span cl
          ...


          In manager area I don’t know where set/create snippets for my pages




          Can you also reply to these my questions:

          Can you tell me the differences between Cipa’s and ncrosslands version of dbEdit (I’ve installed ncrosslands version)?

          Do you confirm me this: dbEdit is used only for manage tables/settings in admin area but for manage the user (front end) area I’ve to use only loopDbChunk??

          dbEdit -> Module (used in backend)
          loopDbChunk -> Snippet (used in frontend)

          is this right??


          is this the right/final version: loopDBChunk_1_2.zip (
          link: http://modxcms.com/forums/index.php?action=dlattach;topic=14654.0;attach=9144


          With "loopDbChunk" Can I only show records or also insert/update/delete (in frontend I mean)




          Thanks!
            • 26931
            • 2,314 Posts
            Hi il_dandi,

            yes, the loopDbChunk Snippet is only to display those db records on the frontend (and paginate). data entry is through the module in the backend,

            1)to install loopDbChunk you need to create a folder "loopDbChunk" in /assets/snippets/ -> assets/snippets/loopDbChunk
            the files "LoopDBChunk.php" "Pagination.php" and "transformFuncs.php" goes in there

            2) create a new snippet ( "Elements" -> "Manage Elements" -> "Snippets" -> "New Snippet" ) named ’loopDbChunk’ and copy the content of the file ’snippet.txt’ into it.

            3) create a chunk named "address" ( "Elements" -> "Manage Elements" -> "Chunks" -> "New Chunk ) with this content:

            <div class="product_block" style="float:left;margin: 0px 20px 20px 0px;background-color: #ada86f;border: 1px solid #666;padding: 5px;">
            <div  class="product_desc">
            first name: <span class="addresscolor">[+forename+]</span><br/>
            surname: <span class="addresscolor">[+surname+]</span><br/>
            address: <span class="addresscolor">[+address+]</span><br/>
            postcode: <span class="addresscolor">[+postcode+]</span><br/>
            town: <span class="addresscolor">[+town+]</span><br/>
            coordinates: <span class="addresscolor">[+coordinates+]</span><br/>
            telephone: <span class="addresscolor">[+telephone_number+]</span><br/>
            website: <span class="addresscolor">[+website+]</span><br/>
            email: <span class="addresscolor">[+email_address+]</span><br/>
            </div>
            <div class="product_details">
            <div style="margin-top: 10px;"><img style="border: 1px solid #fff;"  src="[+county+]" width="200px" height="200px;"></img></div>
            </div>
            </div>


            4) call the Snippte in your template:
            [!loopDbChunk? &tableName=`test_address` &numLinks=`2` &orderby=`town desc` &chunkName=`address` &perPage=`2` &missingValTxt=`--`!]


            cipas and ncrosslands version are just improved versions ( see the threads about details )

            With "loopDbChunk" Can I only show records or also insert/update/delete (in frontend I mean)
            no, only display ... management is in the backend

            for frontend there’s another interesting approach:
            Xedit: http://modxcms.com/forums/index.php?topic=33985.0 i think it can handle custom dbs as well (still in beta)
              • 12793
              • 293 Posts
              I’ve inserted this string


              [!loopDbChunk? &tableName=`test_address` &numLinks=`2` &orderby=`town desc` &chunkName=`address` &perPage=`2` &missingValTxt=`--`!]




              in home page (content area)


              and I show this:

              « MODx Parse Error »
              MODx encountered the following error while attempting to parse the requested resource:
              « PHP Parse Error »

              PHP error debug
              Error: include_once(/Applications/MAMP/htdocs/modx/assets/snippets/loopDbChunk/transformFuncs.php) [function.include-once]: failed to open stream: No such file or directory
              Error type/ Nr.: Warning - 2
              File: /Applications/MAMP/htdocs/modx/manager/includes/document.parser.class.inc.php(770) : eval()’d code
              Line: 40
                • 12793
                • 293 Posts
                About frontend pages that allow me to insert/update/delete

                I’ve read this post

                http://modxcms.com/forums/index.php/topic,33985.20.html

                but I don’t know what I’ve to install to do this


                Very thanks for help me!!
                  • 26931
                  • 2,314 Posts
                  http://modxcms.com/forums/index.php/topic,33985.20.html
                  but I don’t know what I’ve to install to do this

                  you need to ask in this thread, i haven’t used it yet and it’s still in developement
                    • 12793
                    • 293 Posts
                    Thanks for your reply!

                    Can you help me for this:

                    I’ve inserted this string


                    [!loopDbChunk? &tableName=`test_address` &numLinks=`2` &orderby=`town desc` &chunkName=`address` &perPage=`2` &missingValTxt=`--`!]




                    in home page (content area)


                    and I show this:

                    « MODx Parse Error »
                    MODx encountered the following error while attempting to parse the requested resource:
                    « PHP Parse Error »

                    PHP error debug
                    Error: include_once(/Applications/MAMP/htdocs/modx/assets/snippets/loopDbChunk/transformFuncs.php) [function.include-once]: failed to open stream: No such file or directory
                    Error type/ Nr.: Warning - 2
                    File: /Applications/MAMP/htdocs/modx/manager/includes/document.parser.class.inc.php(770) : eval()’d code
                    Line: 40
                      • 26931
                      • 2,314 Posts
                      Error: include_once(/Applications/MAMP/htdocs/modx/assets/snippets/loopDbChunk/transformFuncs.php) [function.include-once]: failed to open stream: No such file or directory
                      is the file transformFuncs.php in the directory "loopDbChunk"?