Page 1 of 1

related records/sections

PostPosted: Wed Jun 27, 2012 7:11 pm
by cookie720
I have two things I need to do, for one of my tables, i only need the latest record to show up. The most recent. Im sure this can be done somehow by using a query to return rows by timestamp in descending order and limit it by 1.
Could someone help me out with this function?
Another thing i would like is to have buttons on each secton, with a link to the list view of those related tabels (thus eliminating the need for the tabs on top) .

right now ive modified block.collapsible sidebar.php found in xataface/lib/smarty/plugins

Code: Select all
<h3 class=\"$class\" style=\"padding-left:0; width:100%;
   $headingstyle\">
   
   $links"."$expansionImage
   <a href='\{$menu.url\}'   />
   $heading</a></h3>


is the code in dataface_record_template.html

Code: Select all
    {foreach from=$menus item="menu" key="name"}
         
                     <li>
                        <a href="{$menu.url}"
                           id="record-actions-menu-{$menu.id}"
                           onmouseup="if (activeButton != null) resetButton(activeButton);"
                           title="{$menu.description}">
                          <img src="{$menu.icon}"
                              alt="" width="20" height="20" />
                          {$menu.label}
                        </a>
                     </li>
                     {/foreach}
what generates the links to the list views??

am i even close to the ball??

Re: related records/sections

PostPosted: Thu Jun 28, 2012 1:37 am
by Jean
For the first question, just use __sql__ in your fields.ini .
Code: Select all
__sql__=


or in your table delegate class
Code: Select all
function __sql__(){
return "";
}

Re: related records/sections

PostPosted: Thu Jun 28, 2012 3:34 am
by cookie720
let me clarify that I primarily want this single record to appear in the related section of a central table.... so there will only ever be that one related row (most recent) per relation

not sure if it would be handy for anyone but here is my solution. (Big thankyou to Jean for heading me in the right direction :mrgreen: )

In my main tables delegate class, i am creating a section:
Code: Select all
   function section__status(&$record){
      $related_records =& $record->getRelatedRecordObjects('status');
      // Let's assume there is only one related record.
      if ( count($related_records) == 0 ) return null;
      $content = 'To Do: '.$related_records[0]->htmlValue('ToDo') // 0 is the first record, 1 is the second and so on
      .'<br>Awaiting: '.$related_records[0]->htmlValue('Awaiting') // 0 is the first record, 1 is the second and so on
;   
      return array(         
         'class'=>'left',   
         'content'=> $content,
         'label'=> 'Status',   
         'order' => 2
      );
   }   


and in my tables delegate class, i am putting
Code: Select all
function __sql__(){
return "SELECT * FROM `status` ORDER BY `StatusID` DESC";
}


Now back to my second question, creating that edit link to go to the tables. (basically moving the related record tabs form the top bar down to each related section header)

any help would be greatly appreciated, and as usual if i find a solution beforehand, i will whack it up on here!

Re: related records/sections

PostPosted: Thu Jun 28, 2012 8:46 pm
by cookie720
well almost there,

I can get exactly what i want when i do this code
Code: Select all
   function section__issues(&$record){
      return array(
         'label'=> 'Issues',
         'class'=>'left',
         'records'=>$record->getRelatedRecordObjects('issues'),
         'edit_url'=>$record->getURL('-action=related_records_list&-table=issues&-relationship=issues')
      );
   }

but the label is always 'edit', and i want to label it what i want, i would like to just use the 'url'=> function, which leaves the section blank....how can i use the 'url'=> section and make my own link?

Re: related records/sections

PostPosted: Wed Jul 04, 2012 10:26 am
by shannah
Currently the "edit_url" label is hard-coded in the block-collapsible sidebar plugin
lib/Smarty/plugins/block.collapsible_sidebar.php

It really needs to be changed to accept another parameter for the edit label.

-Steve

Re: related records/sections

PostPosted: Thu Jul 05, 2012 3:25 am
by cookie720
another question, seeing as i am only allowed one client per matter, is there a way to restrict adding more? (you can add more clicking into clients and adding related record) also, is there a way to link to the client by clicking on their photo or name? I dont want to have to click on edit to list a table of clients (because I only have one) I just want to go straight into the detailed view of that client