2013-05-09 2 views
0

이미지 속성을 얻을이 이렇게 배열 에 가치를 = URL 값에 있는지 확인 page_list :내 다음 코드는 2.Go 배열을 통해 하지 1.Get 현재 URL을 기반으로 Concrete5

$on_this_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 
foreach ($city_array as $sandwich) { 
    if (strpos($on_this_link, $sandwich) == true) { 
     $sandwich = trim($sandwich, '/'); 
     $city  = $sandwich; 
     if ($city == 'newyork') { 
      foreach ($category_array as $double_sandwich) { 
       if (strpos($on_this_link, $double_sandwich) == true) { 
        $double_sandwich = trim($double_sandwich, '/'); 
        $category_is = $double_sandwich; 
        Loader::model('page_list'); 
        $nh = Loader::helper('navigation');     
        $pl = new PageList(); 
        $pl->filterByAttribute('city', '%' . $city . '%', 'like'); 
        $pl->filterByAttribute('category','%'.$category_is.'%','like');     
        $pl->sortByDisplayOrder(); 
        $pagelist = $pl->get(); 
        foreach ($pagelist as $p) { 
        echo '<li> <a href="' . $nh->getLinkToCollection($p) . '">' .htmlspecialchars($p->getCollectionName()) . '</a> </li>'; 
         ?> 
       } 
      } 
    } 
} 

을 그러면 URL이 동일한 속성을 가진 페이지 만 표시됩니다. 이 페이지 각각에 내가 보여주고 싶은 이미지 속성이 있습니다. 어떻게이 이미지 속성을 전달할 수 있습니까 ?? 페이지 목록 블록의 뷰 템플릿의 주석 밖으로

답변

1

확인 : https://github.com/concrete5/concrete5/blob/master/web/concrete/blocks/page_list/view.php#L33

당신은 이미지를 얻을 수는 foreach ($pagelist as $p) 루프 내에서이 같은 일부 코드를 넣어 속성 :

$img = $p->getAttribute('example_image_attribute_handle'); 
    if ($img) { 
     //you could output the original image at its full size like so: 
     echo '<img src="' . $img->getRelativePath() . '" width="' . $img->getAttribute('width') . '" height="' . $img->getAttribute('height') . '" alt="" />'; 

     //or you could reduce the size of the original and output that like so: 
     $thumb = Loader::helper('image')->getThumbnail($img, 200, 100, false); //<--200 is width, 100 is height, and false is for cropping (change to true if you want to crop the image instead of resize proportionally) 
     echo '<img src="' . $thumb->src . '" width="' . $thumb->width . '" height="' . $thumb->height . '" alt="" />'; 
    } 
0

들으 그러나 나는 그것을했다 벌써 다른 길! 사용하지 않았습니다.

Loader :: model ('page_list');

$blockType = BlockType::getByHandle('page_list'); 

를 그리고 블록을 하드 코딩 :

대신 내가 사용!

$th = Loader::helper('text'); 
$ih = Loader::helper('image'); 
$page_current = Page::getCurrentPage(); 
$page_2 = $page_current->getCollectionHandle(); 

$ IMG = $ 페이지 -> getAttribute를 ('제품'); $ thumb = $ ih-> getThumbnail ($ img, 240,150, false);

그리고 내 코드보다 조금 변경 후 :

$on_this_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 
    foreach ($city_array as $sandwich) { 
     if (strpos($on_this_link, $sandwich) == true) { 
      $sandwich = trim($sandwich, '/'); 
      $city  = $sandwich; 
      if ($city == 'newyork') { 
      foreach ($category_array as $double_sandwich) { 
      if (strpos($on_this_link, $double_sandwich) == true) { 
      $double_sandwich = trim($double_sandwich, '/'); 
      $category_is = $double_sandwich; 
      $city_att = $page->getAttribute('city', '%' . $city . '%', 'like'); 
      $sub_cat_att = $page->getAttribute('category','%'.$category_is.'%','like'); ?>    
      <?php if($city == $city_att && $category_is == $sub_cat_att){ ?><li><img src="<?php echo $thumb->src ?>" width="<?php echo $thumb->width ?>" height="<?php echo $thumb->height ?>" alt="" /> 
    <h3> <?php echo $title ?></h3> 
    <div class="product_description"> 
    <?php echo $description ?> 
    </div> 
    <a href="<?php echo $url ?>" target="<?php echo $target ?>">Read More... </a> 
    </li> <?php } ?> <?php 
        } 
       } 
    } 

응답에 대한 그래서 모두가 노력하지만 여전히 들으! 미리보기