Contacts_custom need to show address elements in same row

Status
Not open for further replies.
In an effort to have city, state and zip appear on the same line in the details view of my list, I added the folowing to default_group.php in the contacts_custom template.
Code:
<table>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentname'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        <td>
        </td>
        <td>
        </td>
        <td rowspan="8">
            <?php
            $this->element = $this->elements['establishmentmap'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentaddressstreet'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentaddresscity'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        <td>
            <?php
            $this->element = $this->elements['establishmentaddressstate'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        <td>
            <?php
            $this->element = $this->elements['establishmentaddresszip'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentphone'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentwebsite'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmenthours'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        <tr>
        <td>
            <?php
            $this->element = $this->elements['establishmentdescription'];
            echo $this->loadTemplate('element');
            ?>
        </td>
        </tr>
        </table>
The problem I am running into, of course, is that even though they are in the same row, the state and zip are in their own columns, so the spacing does not work. I was able to accomplish something like this in the div list view template by doing the following in the default_row.php file:
Code:
 <tr>
          <td>
    
    <div <?php echo @$this->cellClass['cidermakers___city']; ?>
         <?php echo @$this->cellClass['cidermakers___state']; ?>>     
         <?php echo @$this->_row->data->cidermakers___city;?>, 
         <?php echo @$this->_row->data->cidermakers___state;?>
    </div>    

</td>
     </tr>

I have tried a bunch of different combinations, but I can not get it to work. I also tried using css, but I could not get that to work either.

Any ideas would be greatly appreciated.

URL: http://ciderweek.ohbusyweaver01.com/index.php/home (click on any of the details links to open the lightbox)
Fabrik: 3.0.6
Joomla: 2.5.6
 
BTW, just to save you this part of the calc element learning curve. people get confused about the 'only calc on save' option.

The calc is always performed, regardless of this setting, when submitting the form, and the result is stored in the table.

If 'calc on save only' is set to Yes, the calculation will ONLY be performed when submitting the form. When rendering a list or details view or visualization, we use the value from the table.

If 'calc on save only' set to No, then every time the element is displayed in any view, it is re-calc'ed. This can lead to slow performance in, say a long List display, where every row is running potentially heavy duty PHP on your calc(s).

Which option you use depends on your scenario. So if your calc only involves (say) concatenating other element from the same row (like turning first and last into full name), then it's safe to say "Yes", as you know the value won't change except when you submit a form.

But if your calc refers to "other stuff" that may be changed outside of a Fabrik form submission, you'd need to set that to No.

Final note - we don't (as yet) re-calc your values when you create or change a calc element. So if you are adding a calc to a form with existing data, or you change the calc code, your exsiting data will not be updated. You'd have to manually edit and save each row, or (my prefered solution) run an SQL query by hand to prime your data, like "UPDATE contacts SET full_name = CONCAT(last_name, ', ', first_name)", or whetever query will achieve the same effect as your calc's PHP code.

[Or of course you could set 'calc on save only' to No, so the value is re-calc'ed on display and doesn't rely on a value being in the table]

The main reason we don't auto-update your calc data when saving the calc element, is that re-calcing a large table isn't something we can do in real time when saving an element, as the save would appear to just hang for ages, and could exceed the max execution time.

When I get some time, I'm going to extend our 'cron' (scheduled tasks) functionality to handle one-off task requests, which can be submitted by other parts of the code. So we could (say) fire off a reCalc request when saving the a calc element, which would then get processed in the background by the task scheduler at some point in the next 5 or 10 minutes.

-- hugh
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top