2014-07-09 1 views
1

이미지 링크를 만들려고하는데 내 이미지 파일이 도움이 될 수 있습니까? 감사합니다Drupal 7 이미지 링크 만들기. 쇼 이미지가 없습니까?

여기 여기 내 hook_menu

내가 이것을 알아낼 질수
 function linking_module_menu() { 

     $items = array(); 

     $items['linking'] = array(
     'title' => 'A Linking module', 
     'page callback' => 'linking_module_basic', 
     'access arguments' => array('access content'), 


    ); 
    return $items; 

    } 

의 내 코드

function linking_module_basic(){ 
    $content = array(); 

    $variables = array(
    'path' => 'sites\all\modules\tshirt.png', 
    'alt' => t('Click to create new shirt'), 
    'title' => t('Create shirt'), 
    ); 

    $content['themed_data'] = array(
     '#type' => 'markup', 
     '#markup' => theme('image', $variables), 
     '#prefix' => '<div class = "linking-module-image"><a href = "https://www.facebook.com/">', 
     '#suffix' => '</div></a>', 
     '#attached' => array(
      'css' => array(
       drupal_get_path('module', 'linking_module') . '/linking_module.css', 
      ), 
     ), 
    ); 

    return $content; 
} 

입니다.

+0

'linking_module_basic'함수를 호출하는 방법 및 위치 –

+0

@prabeengiri ive가 이미 내 게시물을 편집했습니다 ... 당신이 tnx를 도울 수 있기를 바랍니다! – DAY

답변

0

여기에 문제가 있습니다 !!! Drupal은 이미지 경로를 인코딩했습니다!

이미지의 path 값에서 백 슬래시를 슬래시로 변경하고 기본 경로도 추가하십시오.

function linking_module_basic(){ 
    $content = array(); 

    $variables = array(
    'path' => base_path() . 'sites/all/modules/tshirt.png', 
    'alt' => t('Click to create new shirt'), 
    'title' => t('Create shirt'), 
    ); 

    $content['themed_data'] = array(
     '#type' => 'markup', 
     '#markup' => theme('image', $variables), 
     '#prefix' => '<div class = "linking-module-image"><a href = "https://www.facebook.com/">', 
     '#suffix' => '</div></a>', 
     '#attached' => array(
      'css' => array(
       drupal_get_path('module', 'linking_module') . '/linking_module.css', 
      ), 
     ), 
    ); 

    return $content; 
} 

지정한 경로에 이미지가있는 한 이제 작동합니다. !!

+0

감사합니다! @ 프리벤 기리! – DAY

관련 문제