bx_if nested in bx_repeat

Hi

 

I have two problems with my template (see code below).

My first problem: when I use the <bx_if:admin> .. </bx_if:admin> twice (once for the button on top) and once for the Edit link on each row, none of the placeholders are getting exchanged with values, instead all placeholders getting printed like they are e.g. __book_name__ (no PHP error). When I only use <bx_if:admin> once, either for the button or for the rows it works (all the placeholders getting exchanged with the correct values). 

 

Second problem: At the end of each line, I'd like to have an edit link for the admin so the admin can edit books. Therefore I'd have to use the <bx_if:admin> inside an <bx_repeat: tag. But it looks like I cannot access the properties/variables of the book e.g. __url_edit__ when I'm inside the <bx_if:admin> tag.

Maybe I'm doing it all wrong so any advice is appreciated!

 

My Code:

    function actionHome () {
	    

        $this->_oTemplate->pageStart(); // all the code below will be wrapped by the user design

        $aBooks = $this->_oDb->getAllBooks(); // get all Books from database
        if ($aBooks) {
            foreach ($aBooks as $sKey => $aRow) { // add human readable values to the resulted array
                $aBooks[$sKey]['url_view'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aRow['book_id'];
                $aBooks[$sKey]['url_edit'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit/' . $aRow['book_id'];

            }      
              
            $aVars = array ( // define template variables
                'bx_repeat:Books' => $aBooks,
                
               	'bx_if:admin' => array(
              	  	'condition' => $GLOBALS['logged']['admin'],
	                'content' => array(
	                    'createurl' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'add/',
	                )
	             ),   

            );
            echo $this->_oTemplate->parseHtmlByName('main', $aVars); // output posts list
        }
        else {
            echo MsgBox(_t('_Empty'));
        }

        $this->_oTemplate->pageCode(_t('Books'), true); // output is completed, display all output above data wrapped by user design

    }


 

My Template:

<h1>Books</h1>

<bx_if:admin>
	<a href="__createurl__">
		<label class="bx-btn"><span>Add Book</span></label>
	</a>
</bx_if:admin>

<table class="table">
	<bx_repeat:books>
		<tr class="bookTitle">		
				<td>
					<a href="__url_view__" title="Click for details">
						<h2>__book_name__</h2>
					</a>
				</td>
				<td>					
					<a href="__url_view__">
						__book_year__ 
					</a>
				</td>
				<bx_if:admin>
					<td>					
						<a href="__url_edit__">
							Edit
						</a>
					</td>
				</bx_if:admin>
		</tr>
   </bx_repeat:books>		
</table>

 Thank you!

Quote · 24 Nov 2016

This is what i have for a repeat section - maybe this will assist you (pay attention to section in blue - this is where the variable for the repeat section goes:

 

  
   
    function blockAppointments ()
    {
       
        $AllEvents = $GLOBALS['MySQL']->getAll("SELECT * FROM cf_clients_appointments");
        $aEvents = array ();
                    foreach ($AllEvents as $r) {
                    $aEvents[] = array (
                            'id' => $r['id'],
                            'title' => $r['title'],
                            'start' => $r['start'],
                            'end' => $r['end'],
                            'uri' => $r['client_id'],
                        );
                    }
       
        return $this->parseHtmlByName('appointment.html', array('bx_repeat:appointments' => $aEvents, 'todays_date' => date('Y-m-d')));
    } 

 

 

caredesign.net
Quote · 25 Nov 2016
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.