• New Commercial Services Section

    We have now opened a commercial services section here on the forum. If you have a Fabrik project that you wish to have someone work on for you, post it under Help Wanted. If you are an application developer and wish to earn some money helping others, post your details under Fabrik Application Developers.

    Both of these are unmoderated. It will be up to both parties to work out the details and come to an agreement.

Need help with pdf output

ontarget

Active Member
Hi I have a fabrik list with a custom pdf template which echoes all the row data.
/components/com_fabrik/views/list/tmpl/listpdf/default.php
I am trying to grab the value of one element (The course title) {aed_reg_list2___course_title_raw} and echo it as a heading for the pdf. I don't need to repeat it in the table rows as shown in the attachment
Here is the pdf output so far see attachment. using the following code
PHP:
<?php if ($this->params->get('show-title', 1)) {?>
    <?php echo "<img style='width:50%;' src='/images/assets/logo.png' />";?>
    <h1>
        <?php //echo $this->table->label;?>
        Attendance Roll - Blackrock Education Centre
       
    </h1>
    <hr />
    <p>Tutor Name:</p>
   
<?php }?>

<?php //echo $this->table->intro;?>
    <form class="fabrikForm" action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikList">

    <div class="fabrikDataContainer">
        <?php foreach ($this->pluginBeforeList as $c) {
            echo $c;
        }?>
        <div class="boxflex">
            <div class="fabrikList" id="list_<?php echo $this->table->renderid;?>" >
                <?php
                    $gCounter = 0;
                    foreach ($this->rows as $groupedby => $group) {
                        if ($this->isGrouped) {
                ?>
                <div class="fabrik_groupheading">
                    <a href="#" class="toggle">
                        <?php echo FabrikHelperHTML::image('orderasc.png', 'list', $this->tmpl, JText::_('COM_FABRIK_TOGGLE'));?>
                        <?php echo $this->grouptemplates[$groupedby]; ?> ( <?php echo count($group)?> )
                    </a>
                </div>
            <?php }?>
            <div class="fabrik_groupdata">
                <div class="groupdataMsg">
                    <div class="emptyDataMessage" style="<?php echo $this->emptyStyle?>">
                        <?php echo $this->emptyDataMessage; ?>
                    </div>
                </div>
            </div>
            <?php
 

                       
        //User Details
             echo "<table style='width:100%;' border='1'>";
                    echo "<thead style='background:#ccc; padding:10px;'>";
                    echo "<tr>";
                    echo "<th>Course</th>";
                    echo "<th>Date</th>";
                        echo "<th>Name</th>";
                        echo "<th>Teaching Council Num</th>";
                        echo "<th>School Roll </th>";
                        echo "<th>School Name </th>";
                        echo "<th>Signature</th>";
                        echo "</tr>";
                        echo "</thead>";
                foreach ($group as $this->_row) {
                    //echo $this->loadTemplate('row');
                  
                      echo "<tr>";
                      echo "<td>".$this->_row->data->aed_reg_list2___course_title_raw. "</td>";
                      echo "<td>".$this->_row->data->aed_reg_list2___course_date. "</td>";
                      echo "<td>".$this->_row->data->aed_reg_list2___first_name_raw .$this->_row->data->aed_reg_list2___last_name_raw . "</td>";
                        echo "<td>". $this->_row->data->aed_reg_list2___school_tn_raw . "</td>";
                        echo "<td>". $this->_row->data->aed_reg_list2___school_roll_raw . "</td>";
                        echo "<td>". $this->_row->data->aed_reg_list2___school_name_raw . "</td>";
                        echo "<td width='20%'>"."</td>";
                       
                        echo "</tr>";
                       
                }
                echo "</table>";
                    
                   
           
            ?>
            <?php if ($this->hasCalculations) { ?>
                <ul class="fabrik_calculations">
                    <?php
                        foreach ($this->calculations as $cal) {
                            echo "<li class=\"fabrik_row___".$el."\">";
                            echo array_key_exists($groupedby, $cal->grouped ) ? $cal->grouped[$groupedby] : $cal->calc;
                            echo "</li>";
                        }
                    ?>
                </ul>
              <?php }
                  $gCounter++;
              }?>
          </div>
          <?php
              echo $this->nav;
              print_r($this->hiddenFields);
          ?>
      </div>
    </div>
</form>
I have another custom details pdf which works very well with the following code to output elements
PHP:
<?php
$group_name = $this->groups['ED Reg List 2'];
$elements = $group_name->elements;
$coursename = $elements ['aed_reg_list2___course_title_raw']->element;
echo "<h3 style='margin-left:0; margin-top:36%;'> ". $coursename . "</h3>";
?>
but the same code doesnt work in the list template (default.php) file
Can anyone help point me in the right direction!!
 
So each row has the same course name?
Just fetch it from one row (e.g. the first one in the first group)
$coursename = $this->rows[0][0]->data->aed_reg_list2___course_title_raw;
 
Thanks a million Troester that works -
I was very close I was trying:
$coursename = $this->_row->data->aed_reg_list2___course_title_raw;

I'm self taught in php - is the [0][0] bit to do with the position of the data in the array?

All the best
 
In a list you have multiple rows in (maybe multiple, if "grouped by") groups.

So $this_rows is a 2-dim array of groups and records in the groups.
You can see the two loops
foreach ($this->rows as $groupedBy => $group):
...
foreach ($group as $this->_row) :



$this->rows[0][0]->data is holding the data of the first record in the first (and maybe only) group.
For debugging you can always add
var_dump($some-variable);exit; //will show you a blank page with the dump infos
or (with jdump extension installed)
dump($some-variable,'some hint text'); //will open a popup
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top