преработване на php script

Face

Registered
опитвам се да преработяедин компонент за joomla,и срещам известни затруднения.



Код:
<?php include $this->loadTemplate( 'sub_listingDetails.tpl.php' ) ?>

<center><div class="mtframe">

	<table class="mtborder" cellpadding="4" cellspacing="1" border="0" width="100%">
	<tr>
		<th class="thead" colspan="4"><?php echo $this->_MT_LANG->LISTING_INFORMATION ?><th>
	</tr>


	<?php if ( !empty($this->link->address) || !empty($this->link->city) || !empty($this->link->state) || !empty($this->link->country) ) { ?>
	<tr>
		<td width="25%" class="mtdata" valign="top"><b><?php echo $this->_MT_LANG->ADDRESS ?>:</b></td>
		<td class="mtdata" width="75%">
			<?php echo $this->link->address ?><br />
			<?php echo $this->link->city ?><br />
			<?php echo $this->link->state ?> <?php echo $this->link->postcode ?><br />
			<?php echo $this->link->country ?><br />		</td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->telephone) ) { ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->TELEPHONE ?>:</b></td>
		<td class="mtdata"><?php echo $this->link->telephone ?></td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->fax) ) { ?>
	<tr>
		<td class="mtdata"><b><b><?php echo $this->_MT_LANG->FAX ?></b>:</b></td>
		<td class="mtdata"><?php echo $this->link->fax ?></td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->email) && $this->mt_show_email ) : ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->EMAIL ?>:</b></td>
		<td class="mtdata"><?php echo mosHTML::emailCloaking($this->link->email, 1) ?></td>
	</tr>
	<?php endif; ?>

	<?php if ( !empty($this->link->website) ) { ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->WEBSITE ?>:</b></td>
		<td class="mtdata"><a href="<?php echo $this->link->website ?>" target="_blank"><?php echo $this->link->website ?></a></td>
	</tr>
	<?php } ?>
		<?php 
		for ($i=1;$i<=30;$i++) {
			$custom_field = "cust_".$i;
if ( !empty($this->custom_fields[$custom_field]->caption) && !empty($this->link->$custom_field) )			
 {	
	?>
	<tr>
		<td class="mtdata"><b><?php echo $this->custom_fields[$custom_field]->caption ?>:</b></td>
	    <td class="mtdata"><?php echo $this->link->$custom_field ?></td>
	</tr>
	<?php 
			}
		} 
	?>
	<?php if ($this->mt_show_rating): ?>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->AVERAGE_VISITOR_RATING ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_rating ?> (<?php echo $this->_MT_LANG->OUT_OF_FIVE ?>)</td>
	</tr>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->NUMBER_OF_RATINGS ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_votes ?></td>
	</tr>
	<?php endif; ?>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->HITS ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_hits ?></td>
	</tr>

	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->ADDED ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_created ?></td>
	</tr>

	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->MODIFIED ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_modified ?></td>
	</tr>
	</table>

</div></center>

<?php if ($this->mt_show_review) include $this->loadTemplate( 'sub_reviews.tpl.php' ) ?>

има възможност за добавяне на полета
тази част играе ролята тук при вузуализацията

Код:
<?php } ?>
		<?php 
		for ($i=1;$i<=30;$i++) {
			$custom_field = "cust_".$i;
if ( !empty($this->custom_fields[$custom_field]->caption) && !empty($this->link->$custom_field) )			
 {	
	?>
	<tr>
		<td class="mtdata"><b><?php echo $this->custom_fields[$custom_field]->caption ?>:</b></td>
	    <td class="mtdata"><?php echo $this->link->$custom_field ?></td>
	</tr>
	<?php 
			}
		} 
	?>[
Код:
<?php } ?>
		<?php 
		for ($i=1;$i<=30;$i++) {
			$custom_field = "cust_".$i;
if ( !empty($this->custom_fields[$custom_field]->caption) && !empty($this->link->$custom_field) )			
 {	
	?>
тук указваколко полета да има допълнителни и да се показват само пълните
искма обаче от тези допълнителни полета който могат да се покажат всяко едно да излиза в определена част от нова таблица която аз стздавам
Код:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="3"> </td>
  </tr>
  <tr>
    <td colspan="3"> </td>
  </tr>
  <tr>
    <td rowspan="4"> </td>
    <td rowspan="2"> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
  </tr>
  <tr>
    <td rowspan="2"> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
  </tr>
  <tr>
    <td rowspan="4"> </td>
    <td rowspan="2"> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
  </tr>
  <tr>
    <td rowspan="2"> </td>
    <td> </td>
  </tr>
  <tr>
    <td> </td>
  </tr>
</table>
в базата тези колони са с имена cust_1
опитвам така да изкарам инофото
Код:
<?php echo $this->link->$cust_1 ?>
като слагам това с всяка клетка на таблицата, като сменям само номера на колонота, но не успявам да го направя. Как трява да се напише да прави. Правянякакви опити, но досега нищо успешно.
 

Admin

Registered
Не знам къде точно го слагаш това но ако е под горния код трябва да е така:

<?php
echo $this->link->cust_1
?>

без $
 

Face

Registered
Мерси тка тана резултатите излизат, но сега се получи една дивотия, че нешщата излзиа в толква нови таблици, колкото са и добанеите полета
на мен ми трява само една а те илзиат 14 :lol:

Код:
<?php include $this->loadTemplate( 'sub_listingDetails.tpl.php' ) ?>

<center><div class="mtframe">

	<table class="mtborder" cellpadding="4" cellspacing="1" border="0" width="100%">
	<tr>
		<th class="thead" colspan="4"><?php echo $this->_MT_LANG->LISTING_INFORMATION ?><th>
	</tr>


	<?php if ( !empty($this->link->address) || !empty($this->link->city) || !empty($this->link->state) || !empty($this->link->country) ) { ?>
	<tr>
		<td width="25%" class="mtdata" valign="top"><b><?php echo $this->_MT_LANG->ADDRESS ?>:</b></td>
		<td class="mtdata" width="75%">
			<?php echo $this->link->address ?><br />
			<?php echo $this->link->city ?><br />
			<?php echo $this->link->state ?> <?php echo $this->link->postcode ?><br />
			<?php echo $this->link->country ?><br />		</td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->telephone) ) { ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->TELEPHONE ?>:</b></td>
		<td class="mtdata"><?php echo $this->link->telephone ?></td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->fax) ) { ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->FAX ?>:</b></td>
		<td class="mtdata"><?php echo $this->link->fax ?></td>
	</tr>
	<?php } ?>
	<?php if ( !empty($this->link->email) && $this->mt_show_email ) : ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->EMAIL ?>:</b></td>
		<td class="mtdata"><?php echo mosHTML::emailCloaking($this->link->email, 1) ?></td>
	</tr>
	<?php endif; ?>

	<?php if ( !empty($this->link->website) ) { ?>
	<tr>
		<td class="mtdata"><b><?php echo $this->_MT_LANG->WEBSITE ?>:</b></td>
		<td class="mtdata"><a href="<?php echo $this->link->website ?>" target="_blank"><?php echo $this->link->website ?></a></td>
	</tr>
	<?php } ?>

	<?php 
		for ($i=1;$i<=30;$i++) {
			$custom_field = "cust_".$i;
			if ( !empty($this->custom_fields[$custom_field]->caption) && !empty($this->link->$custom_field) ) {
	?>
	<tr>
		<td colspan="2" class="mtdata">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="3"> </td>
  </tr>
  <tr>
    <td colspan="3"> </td>
  </tr>
  <tr>
    <td rowspan="4"><?php echo $this->link->cust_1 ?></td>
    <td rowspan="2"><?php echo $this->link->cust_3 ?></td>
    <td><?php echo $this->link->cust_7 ?></td>
  </tr>
  <tr>
    <td><?php echo $this->link->cust_8 ?></td>
  </tr>
  <tr>
    <td rowspan="2"><?php echo $this->link->cust_4 ?></td>
    <td><?php echo $this->link->cust_9 ?></td>
  </tr>
  <tr>
    <td><?php echo $this->link->cust_10 ?></td>
  </tr>
  <tr>
    <td rowspan="4"><?php echo $this->link->cust_2 ?></td>
    <td rowspan="2"><?php echo $this->link->cust_5 ?></td>
    <td><?php echo $this->link->cust_11 ?></td>
  </tr>
  <tr>
    <td><?php echo $this->link->cust_12 ?></td>
  </tr>
  <tr>
    <td rowspan="2"><?php echo $this->link->cust_6 ?></td>
    <td><?php echo $this->link->cust_13 ?></td>
  </tr>
  <tr>
    <td><?php echo $this->link->cust_14 ?></td>
  </tr>
</table>
		</td>
	  </tr>
	<?php 
			}
		} 
	?>
	<?php if ($this->mt_show_rating): ?>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->AVERAGE_VISITOR_RATING ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_rating ?> (<?php echo $this->_MT_LANG->OUT_OF_FIVE ?>)</td>
	</tr>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->NUMBER_OF_RATINGS ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_votes ?></td>
	</tr>
	<?php endif; ?>
	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->HITS ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_hits ?></td>
	</tr>

	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->ADDED ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_created ?></td>
	</tr>

	<tr>
		<td class="mtdata"><strong><?php echo $this->_MT_LANG->MODIFIED ?>:</strong></td>
		<td class="mtdata"><?php echo $this->link->link_modified ?></td>
	</tr>
	</table>

</div></center>

<?php if ($this->mt_show_review) include $this->loadTemplate( 'sub_reviews.tpl.php' ) ?>

махнат тези два реда php защото ми излизат и тези полете който получавма в таблиците

Код:
<b><?php echo $this->custom_fields[$custom_field]->caption ?>:</b><?php echo $this->link->$custom_field ?>

ноп това не реши крайни ефект, имам от таблицата 14 колони от който визоализрам иноформацията, но се получават и 14 нови таблици, :lol: :lol: с една и съща инофмация
в същност ще се получат толкова колкото полета добавя
Код:
<?php
echo $this->link->cust_1
?>
 

Face

Registered
мисля че реших проблема :)


Код:
<?php
      for ($i=1;$i<=30;$i++) {
         $custom_field = "cust_".$i;
         if ( !empty($this->custom_fields[$custom_field]->caption) && !empty($this->link->$custom_field) ) {
   ?>

ето в тази част направих промяната и му задох да показва 1 от едно1



Код:
for ($i=1;$i<=1;$i++) {


Благодаря много за помощо :D :?:
 

Горе