Не получается вывести поле

Главные вкладки

Аватар пользователя rafter rafter 23 марта 2015 в 8:42

Здравствуйте.
Я в php начинающий.
Мне один товарищ написал пол года назад два шаблона под типы материалов: node--event.tpl.php node--touristinformationcenter.tpl.php
В материале touristinformationcenter поля из event.
Я создал новое поле field_ptel в event, оно выводится. А подтянуть его в touristinformationcenter, не выводится.

Код привожу:
node--event.tpl.php


<?php if (!$page) { ?>

<div itemscope itemprop="event" itemtype="http://schema.org/Event" class="event clearfix">

  <h2 class="etitle" itemprop="name"><?php print $title?></h2>
  
   <div class="columns"> 

  <div class="column">
  <?php print render($content['field_image']); ?>
  </div>

  <div class="column">
    <div  itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
    <div class="readmore">
     <a href="<?php echo url('node/'.$node->nid?>"  itemprop="url" >Подробней ...</a> 
    </div>
      <div><p><b>Бюджетная цена:</b></p><span itemprop="lowPrice" content="$<?php print isset($node->field_price['und'][0]['value']) ? $node->field_price['und'][0]['value'] : ''?>"><?php print isset($node->field_price['und'][0]['value']) ? $node->field_price['und'][0]['value'] : ''?> USD</span></div>
      <div><p><b>Цена VIP:</b></p><span itemprop="highPrice" content="$<?php print isset($node->field_vip['und'][0]['value']) ? $node->field_vip['und'][0]['value'] : ''?>"><?php print isset($node->field_vip['und'][0]['value']) ? $node->field_vip['und'][0]['value'] : ''?> USD</span></div>
    </div>
  <div><p><b>Длительность:</b></p><span itemprop="duration" content="<?php echo bestmobile_plural($node->field_duration['und'][0]['value'], array('день''дня''дней')); ?>"><?php echo bestmobile_plural($node->field_duration['und'][0]['value'], array('день''дня''дней')); ?></span></div>

    <p><b>Регион:</b></p>
     <!------------мое добавление------------------> 
 <div itemprop="location" itemscope itemtype="http://schema.org/Place">
 <span itemprop="telephone" ><?php print render($content['field_ptel']); ?></span>
 <span>Test</span>  
<span itemprop="name"><?php print render($content['field_region']); ?></span>
    
    
    <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
      <span itemprop="addressLocality"><?php print render($content['field_physical_address_of_the_it']); ?></span>
      
      
    </div>
  </div>

<!----------------------------------------------->

  </div> 

  <div class="column last">

    <?php $nid2=$node->field_linkt['und'][0]['nid'];?>
    <?php $node2 node_load($nid2);?>
    <table>
    <thead>
    <b>Даты тура:</b>
    </thead>
    <?php $i=0?>
    <?php 
    
if ($node2->field_date['und']) {
       foreach (
$node2->field_date['und'] as $key) { 
        
$new_date strtotime(($node2->field_date['und'][$i]['value']))+(86400*$node->field_datemod['und'][0]['value']);
      print 
'<tr>';
      print 
'<td><meta itemprop="startDate" content="'.date('Y-m-d',$new_date).'">'.date('d',$new_date) .'</td><td> '.t(date('F',$new_date)) .'</td><td> 'date('Y',$new_date).'</td>';
      print 
'</tr>';
      
$i=$i+1;
    }} 
?>
    </table>
  </div>

    
      </div>

    
    <div class="clearfix"></div><br />

    <div itemprop="description"><?php print render($content['body']); ?>
     
    
    </div>

   

  

<?php } else { ?>
<div itemscope itemtype="http://schema.org/Event">

  <div id="node-<?php print $node->nid?>" class="<?php print $classes?>"<?php print $attributes?>>
  <article class="post<?php print ' '.strip_tags(render($content['field_icon'])); ?>">
    
  <section class="main clear">
  <h1 class="title" itemprop="name"><a href="<?php print $node_url?>" title="<?php print $title?>"><span class="name"><?php print $title?></span></a></h1>
    
    
    <div class="content">
    
        <?php print render($content['field_image']); ?>
        <div  style="float:left;font-weight: bold; width: 72px;" ></div>

        <div class="pric">
        <p><b>Регион:</b></p>
        <!------------мое добавление------------------> 
 <div itemprop="location" itemscope itemtype="http://schema.org/Place">
 
 
<div itemprop="name"><?php print render($content['field_region']); ?></div>
  <span itemprop="telephone" ><?php print render($content['field_ptel']); ?></span>  
    
    <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
    
      <span itemprop="addressLocality"><?php print render($content['field_physical_address_of_the_it']); ?></span>
      
    </div>
    
  </div>
 
<!----------------------------------------------->
        <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
        <a  href="<?php echo url('node/'.$node2->nid?>" itemprop="url" >Подробней о туре</a>
            <div><p>Цена бюджета:</p><span itemprop="lowPrice" content="$<?php print isset($node->field_price['und'][0]['value']) ? $node->field_price['und'][0]['value'] : ''?>"><?php print isset($node->field_price['und'][0]['value']) ? $node->field_price['und'][0]['value'] : ''?> USD</span></div>
            <div><p>Цена VIP:</p><span itemprop="highPrice" content="$<?php print isset($node->field_vip['und'][0]['value']) ? $node->field_vip['und'][0]['value'] : ''?>"><?php print isset($node->field_vip['und'][0]['value']) ? $node->field_vip['und'][0]['value'] : ''?> USD</span></div>
      </div>
      <?php if(!empty($node->field_duration['und'][0]['value'])):?>
      <div><p>Длительность:</p><span itemprop="duration" content="<?php echo bestmobile_plural($node->field_duration['und'][0]['value'], array('день''дня''дней')); ?>"><?php echo bestmobile_plural($node->field_duration['und'][0]['value'], array('день''дня''дней')); ?></span></div>
    <?php endif; ?>
  </div>
        
        
          
          <div id="date">

            <?php $nid2=$node->field_linkt['und'][0]['nid'];?>
            <?php $node2 node_load($nid2);?>
            <table>
            <thead>
            <b>Даты тура:</b>
            </thead>
            <?php $i=0?>
            <?php 
            
if ($node2->field_date['und']) {
             foreach (
$node2->field_date['und'] as $key) { 
        
$new_date strtotime(($node2->field_date['und'][$i]['value']))+(86400*$node->field_datemod['und'][0]['value']);
            print 
'<tr>';
            print 
'<td><meta itemprop="startDate" content="'.date('Y-m-d',$new_date).'">'.date('d',$new_date) .'</td><td> '.t(date('F',$new_date)) .'</td><td> 'date('Y',$new_date).'</td>';
            print 
'</tr>';
            
$i=$i+1;
            }} 
?>
            </table>
        </div>
         
    <div class="clearfix"><br /></div>
    
           <div itemprop="description"><?php print render($content['body']); ?></div>
           <?php print render($content['field_marshrut']); ?>
           <?php // print render($content['field_linkt']); ?>

       <div class="event_links">
         
         <a href="<?php echo url('node/1202').'?n='.$node2->nid ?>">Заказать тур</a>
       </div>
    </div>
    </section>
    
    
    
    
    
  <?php if ($my_additional_field render($content['my_additional_field'])) { ?>
    <div class="social clear">
            <?php print $my_additional_field?>
    </div>
  <?php ?>
  <?php if ($display_submitted): ?>
  <ul class="meta">
    <?php if ($node->comment and !($node->comment == and !$node->comment_count)) { ?><li class="comments"><a href="<?php print url("node/$node->nid", array('fragment' => 'comment-form')) ?>"><?php print format_plural($node->comment_count'1 Comment''count Comments'?></a></li><?php ?>
    <li class="date"><?php print format_date($node->created,'custom','M j Y'); ?></li>
    <?php if ($field_category render($content['field_category'])) { ?><li class="category"><?php print $field_category?>&nbsp;</li><?php ?>
    <?php if ($field_tags render($content['field_tags'])) { ?><li class="tags"><?php print $field_tags?>&nbsp;</li><?php ?>
    <?php /* ?><li class="link"><?php print render($content['links']); ?></li><?php */ ?>
  </ul>
  <?php endif; ?>
  <?php if ($links render($content['links'])): ?>
    <div class="social clear"><?php print $links?></div>
  <?php endif; ?>
</article>
</div>
<?php print render($content['comments']); ?> 
  <?php unset($content['field_image']);
      unset(
$content['links']);
      unset(
$content['comments']);
      unset(
$content['body']);
      unset(
$content['#printed']);
      unset(
$content['#sorted']);
      unset(
$content['#children']);
      unset(
$content['field_tags']);
      unset(
$content['field_category']);
      unset(
$content['my_additional_field']);
        
//print '<pre>'. check_plain(print_r($content, 1)) .'</pre>'; ?>
<?php 
?>
</div>
?>

Файл node--touristinformationcenter.tpl.php


<?php 
hide
($content['field_events']); 
hide($content['field_event_title']); 
?>

<?php if (!$page) { ?>

<article class="post<?php print ' '.strip_tags(render($content['field_icon'])); ?>">

  <section class="main clear">

    <h1 class="title"><a href="<?php print $node_url?>" title="<?php print $title?>"><?php print $title?></a></h1>

    <div class="content">

      <?php

        

// We hide the comments and links now so that we can render them later.

        

hide($content['comments']);

        

hide($content['links']);

        

hide($content['field_tags']);

        

hide($content['field_category']);

        

/*hide($content['my_additional_field']);*/

        

print render($content);

      

?>
        
        <!------------------------------> 
      <div  itemscope itemprop="name"><?php print render($content['title']); ?></div>
    
    <div  itemscope  itemprop="address" itemtype="http://schema.org/PostalAddress">
    <span>Test 2</span>
      <span itemprop="addressLocality"><?php print render($content['field_physical_address_of_the_it']); ?></span>
       <span itemprop="addressLocality"><?php print render($content['field_physical_address_of_the_it']); ?></span>
       <span itemprop="telephone"><?php print render($content['field_ptel']); ?></span>
       <span> TEST </span>
       
    </div>
    
  </div>

<!----------------------------------------------->  

    </div>

  </section>

  <?php if ($display_submitted): ?>

  <ul class="meta">

    <?php if ($node->comment and !($node->comment == and !$node->comment_count)) { ?><li class="comments"><a href="<?php print url("node/$node->nid", array('fragment' => 'comment-form')) ?>"><?php print format_plural($node->comment_count'1 Comment''count Comments'?></a></li><?php ?>

    <li class="date"><?php print format_date($node->created,'custom','M j Y'); ?></li>

    <?php if ($field_category render($content['field_category'])) { ?><li class="category"><?php print $field_category?>&nbsp;</li><?php ?>

    <?php if ($field_tags render($content['field_tags'])) { ?><li class="tags"><?php print $field_tags?>&nbsp;</li><?php ?>

    <?php /* ?><li class="link"><?php print render($content['links']); ?></li><?php */ ?>
    
    

  </ul>

  <?php endif; ?>

</article>

<?php } else { ?>

<div itemscope itemtype="http://schema.org/TouristInformationCenter">

<div id="node-<?php print $node->nid?>" class="<?php print $classes?>"<?php print $attributes?>>

<article class="post<?php print ' '.strip_tags(render($content['field_icon'])); ?>">

  <section class="main clear">
  

    <h1 class="title"><a href="<?php print $node_url?>" title="<?php print $title?>"><?php print $title?></a></h1>
    

    <?php $title = isset($_GET['title']) ? $_GET['title'] : ''?>

    <?php //$node = isset($_GET['title']) ? $_GET['title'] : ''; ?>

        <a href="javascript:history.go(-1)"><?php print $title?></a>
        
     
     

    <div class="content">
     

      <?php

        // We hide the comments and links now so that we can render them later.

        hide($content['comments']);

        hide($content['links']);

        hide($content['field_tags']);

        hide($content['field_category']);

        hide($content['my_additional_field']);
        
        
hide($content['field_physical_address_of_the_it']);
        
        
hide($content['field_ptel']);

        print render($content);

      ?>
        
   <!-------------------------------------->
  
      <div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
      <span itemprop="addressLocality"><?php print render($content['field_physical_address_of_the_it']); ?></span>
 
    </div>
      
    <span itemprop="name" ><?php print $node->title?></span>
    <span itemprop="telephone" ><?php print render($content['field_ptel']); ?></span>  
   
   <!---------------------------------------->

    </div>
                
                 

    </section>
    
     
    

  <?php if(!empty($node->field_events['und'])): // âûâîä èâåíòîâ?>

  <?php 
  
echo '<h2 class="event_title">'.$node->field_event_title['und'][0]['value'].'</h2>';
  echo 
'<span class="event_title">'.$node->field_physical_address_of_the_it['und'][0]['value'].'</span>';
  echo 
'<span class="event_title">'.$node->field_ptel['und'][0]['value'].'</span>';
  foreach(
$node->field_events['und'] as $event){
    echo 
render(node_view($event['entity'], 'teaser'));
   }
  
?>

   
  <?php endif;?>

  <?php if ($my_additional_field render($content['my_additional_field'])) { ?>

    <div class="social clear">

            <?php print $my_additional_field?>
                        

    </div>

  <?php ?>

  <?php if ($display_submitted): ?>

  <ul class="meta">

    <?php if ($node->comment and !($node->comment == and !$node->comment_count)) { ?><li class="comments"><a href="<?php print url("node/$node->nid", array('fragment' => 'comment-form')) ?>"><?php print format_plural($node->comment_count'1 Comment''count Comments'?></a></li><?php ?>

    <li class="date"><?php print format_date($node->created,'custom','M j Y'); ?></li>

    <?php if ($field_category render($content['field_category'])) { ?><li class="category"><?php print $field_category?>&nbsp;</li><?php ?>
    

    <?php if ($field_physical_address_of_the_it render($content['field_physical_address_of_the_it'])) { ?><li class="<?php if ($field_physical_address_of_the_it render($content['field_physical_address_of_the_it'])) { ?><li class="category"><?php print $field_physical_address_of_the_it?>&nbsp;</li><?php ?>"><?php print $field_physical_address_of_the_it?>&nbsp;</li><?php ?>
  
   
  
    <?php if ($field_tags render($content['field_tags'])) { ?><li class="tags"><?php print $field_tags?>&nbsp;</li><?php ?>

    <?php /* ?><li class="link"><?php print render($content['links']); ?></li><?php */ ?>

  </ul>

  <?php endif; ?>

  <?php if ($links render($content['links'])): ?>

    <div class="social clear"><?php print $links?></div>

  <?php endif; ?>

</article>

<?php print render($content['comments']); ?> 

  <?php unset($content['field_image']);

      unset($content['links']);

      unset($content['comments']);

      unset($content['body']);

      unset($content['#printed']);

      unset($content['#sorted']);

      unset($content['#children']);

      unset($content['field_tags']);

      unset($content['field_category']);

      unset($content['my_additional_field']);

        //print '<pre>'. check_plain(print_r($content, 1)) .'</pre>'; ?>

    

        </div>

        </div>

<?php ?>

Ссылка на страницу event http://ultexplorer.com.ua/tibet/tibet-1/zapadniy-tibet-kailas.html
Ссылка на страницу touristinformationcenter http://ultexplorer.com.ua/tibet

Комментарии