We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22303 MODX Staff
    • 10,725 Posts
    Quote from: doze at Apr 26, 2006, 02:17 PM

    In quick it seems that this class would work only if FURLs are enabled.. But I might be wrong.

    You are correct, I developed this originally with friendly URLs, my bad... I’ll try and develop a proper solution to it, but you can modify the prepareOrderByLinks() function to use & if you know you’re not going to use friendly URLs with it.

      • 17833
      • 28 Posts
      bitten by furls again ... thanks, thats got it fixed smiley It was pretty straight forward to get it to handle the extra parameters i needed as well. thanks again.
        • 17833
        • 28 Posts
        Sorry to keep pestering you with this OpenGeek, but I have another little problem I need your help with.

        I have a table in which the the index is called ’id’ ... I’ve set the ActionFieldName, and the CellAction with the idea that it would open up another page showing all of the associated details with that record. The link that is generated ends up being "index.php?id=24&id=18" I tried giving the field an alias (’rfi’), but the generated link always ends up failing. I was hoping for "index.php?id=25&rfi=18"

        Will I have to change the field name in the db or is there another way to approach this?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: Machiavelli at Apr 27, 2006, 12:05 PM

          Sorry to keep pestering you with this OpenGeek, but I have another little problem I need your help with.

          I have a table in which the the index is called ’id’ ... I’ve set the ActionFieldName, and the CellAction with the idea that it would open up another page showing all of the associated details with that record. The link that is generated ends up being "index.php?id=24&id=18" I tried giving the field an alias (’rfi’), but the generated link always ends up failing. I was hoping for "index.php?id=25&rfi=18"

          Will I have to change the field name in the db or is there another way to approach this?

          Ah yes, since id is used by MODx URLs to identify the document id (when not using Friendly URLs), this can also cause some problems. This is easy to address by setting the name of the array field that holds the id column value to something unique. Consider a function to build the array (in this case I have a class with all these functions that I load in my snippets)...
          <?php
          	function getIndustries() {
          		$query= "SELECT COUNT(id) FROM industries";
          		$this->numRecords= $this->db->getValue($query);
          		
          		$results= false;
          		$query= "SELECT i.*, COUNT(DISTINCT aoe.id) AS area_count FROM industries i LEFT JOIN areas_of_expertise aoe ON aoe.industry_id = i.id GROUP BY i.id" . $this->handleSorting() . $this->handlePaging();
          		if ($ds= $this->db->query($query)) {
          			while ($row= $this->db->getRow($ds)) {
          				$results[]= array(
          					'industry_id'=> $row['id'],
          					'name'=> stripslashes($row['name']),
          					'description'=> stripslashes($row['description']),
          					'area_count'=> $row['area_count'],
          				);
          			}
          		}
          		return $results;
          	}
          ?>


          Then I can use this to still sort on the proper actual column value when setting the headers...
          <?php
          ...
          
          $industries= $objExtranet->getIndustries();
          
          $industryTableHeader= array(
          	'industry_id'=> $objTable->prepareOrderByLink('id', 'IndustryID'),
          	'name'=> $objTable->prepareOrderByLink('name', 'Name'),
          	'description'=> $objTable->prepareOrderByLink('description', 'Description'),
          	'area_count'=> $objTable->prepareOrderByLink('area_count', 'Areas of Expertise'),
          	'is_core'=> $objTable->prepareOrderByLink('is_core', 'Is Core?'),
          );
          
          $objTable->setActionFieldName('industry_id');
          ...
          
          ?>

          Hope that helps you out...
            • 17833
            • 28 Posts
            I like the method you recommended, but i’m having a hard time pulling it off myself. I keep getting fatal errors and assume it’s because i’m not calling the function properly.  Could you break it down, how you are calling getIndustries()?

            the error i’m getting is ’call to a member function on a non-object’ when it hits the following line:

              $this->numRecords= $this->db->getValue($query);

            [edit]
            ok, i fixed the above problem, but another one comes up when the function hits "$this->handleSorting() "

            I think i understand whats causing the problem alright ... just need to figure out how to apply it wink
              • 22303 MODX Staff
              • 10,725 Posts
              I just keep forgetting about various ways I implemented this when developing it initially; the references to $this-> are within a proprietary class I had to encapsulate all my various functions used in my application. That file is included and has it’s own instance of a DBAPI object to interact with the DB from. You can use $modx->db in place of $this-> and the other functions should all be on the MakeTable class instance itself rather than on $this-> as I misled you with my code sample.

              embarrassed Sorry...like I said I need to re-organize this a bit, add a module for making this even easier to set-up and use (i.e. a UI for defining the table options), and document everything a bit better, but...I also want to finish coding 1.0... (sigh)
                • 11975
                • 2,542 Posts
                Hi opengeek,

                I’m using MakeTable in a module.
                As I have tabs and multiple instances of maketable (1 per tab), every time I’m changing the display per page settings on one table, all the tables are affected, the pagination has the same issue.

                Is there anyway to bound changes to the the current table?

                thx for your help.


                :-)
                  Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: heliotrope at Dec 04, 2006, 07:52 AM

                  I’m using MakeTable in a module.
                  As I have tabs and multiple instances of maketable (1 per tab), every time I’m changing the display per page settings on one table, all the tables are affected, the pagination has the same issue.

                  Is there anyway to bound changes to the the current table?
                  @Heliotrope: Though I have improved these features in the latest version of MakeTable that is a part of xPDO (see http://mirror1.cvsdude.com/trac/rethrash/xpdo/browser/trunk/xpdo/table/maketable.class.php), it is still looking for hardcoded REQUEST parameters to determine the number of records to display, sorting, etc. You could take a look at those revisions, add some changes to have it look for instance specific REQUEST parameters to determine records to display per page, as well as instance-isolated pagination tracking and sorting, then port it back down as a new version of MakeTable (i.e. without xPDO-specific code).
                    • 11975
                    • 2,542 Posts
                    Thanks for the fast reply.

                    I’ve found a work around close to your suggestion.
                    I’m looking for a GET vars and activate the handlingPagination() when needed foreach table.
                    I didn’t want to change the maketable class.

                    Whatever thanks for sharing these two classes.

                    :-)
                      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                      • 7885
                      • 40 Posts
                      hi OpenGeek smiley could you please giveus a little example of usage from maketable and makeform together???

                      it would be really usefull, it doesn’t matter if the example database has 1 field i just need to understand the workflow.. i’m not a developer, but i’m good at following instructions wink

                      thanks for all in advance grin
                        visit us at www.dospuntocero.cl