2012-03-23 2 views
0

다른 테마 템플릿으로 4 가지 테마가있는 Drupal 사이트를 만들고 있습니다.Drupal 7 테마 전환 및 내용 관련성

모든 4 가지 테마의 모든 콘텐츠를 제어하려면 동일한 Drupal 데이터베이스를 사용해야합니다.

각 테마마다 분류 체계를 설정하므로 콘텐츠를 만들 때 네 가지 테마 중 하나에 적용 할 수 있습니다.

URL은

mysite.com/theme1/node/21

그리고

처럼

mysite.com/theme2/node/2

또한 I가해야 할 일을 볼 필요가

mysite.com/theme1은

을 기반으로 해당 테마의 page-front.tpl.php를 가져와야합니다.210

나는 그 사이트에 적용된 택 소노 미 용어가있는 콘텐츠 만 가져 오는 방법을 알지 못한다는 점을 제외하고는 괜찮은 themekey를 사용해 보았습니다.

나는 그것을 만이

mysite.com/theme2/node/1

처럼 뭔가 동작하지 않습니다

mysite.com/node/1/theme2

올바른 방향으로 나를 지적하기 위해 제공 할 수있는 아이디어 나 아이디어가 있으면 크게 감사하겠습니다.

답변

1

아마도 이렇게하는 데는 많은 방법이 있지만 이것이 내가하는 방법입니다.

  • taxnonomy term을 필터링하여 name에서 tid로 변환되는 인수가있는보기 표시를 만듭니다. 이보기는 첫 페이지로 작동합니다.
  • 또한 두 개의 인수가 첫 번째 인수 택 소노 미 term 이름으로 태그 지정된 노드인지 확인하는 두 개의 인수를 사용하는보기 표시를 작성하십시오. 그것이 반환되지 않으면.
  • 코드에서 이러한보기에만 액세스하므로 페이지 또는 블록 인 경우 중요하지 않습니다. 그들이 페이지 인 경우 테마와 동일한 이름을 지정하지 마십시오. 그런 다음 메뉴 항목을 덮어 씁니다.

node.module과 마찬가지로 쿼리 할 수도 있지만 개인적으로 필자는 필터링을 수행하기 위해 뷰를 사용하는 것을 선호합니다. example_menu() 함수의 views_embed_view() 인수에 익숙하지 않은 경우 example_menu() 함수에서 찾을 수 있습니다. documentation here

이 스 니펫에는 오타가있을 수 있지만 지금은 아무것도 볼 수 없습니다. 좋은 자료 : http://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7

/** 
* Implements hook_menu(). 
* 
* Here we define the new frontpages as well as a node view page for all them custom themes. 
*/ 
function example_menu() { 
    $items = array(); 
    foreach (example_custom_themes() as $theme) { 
    // Define the front page 
    $items[$theme] = array(
     'page callback' => 'views_embed_view', 
     'page arguments' => array('VIEW', 'DISPLAY', $theme), // The front page view 
     'access arguments' => array('access content'), 
     'type' => MENU_CALLBACK, 
     'theme callback' => 'example_theme_callback', 
     'theme arguments' => array($theme), 
    ); 
    // Define the node views 
    $items[$theme . '/node/%node'] = array(
     'title callback' => 'node_page_title', 
     'title arguments' => array(1), 
     'page callback' => 'views_embed_view', 
     'page arguments' => array('VIEW', 'DISPLAY', $theme, 1), // The node view display 
     'access callback' => 'node_access', 
     'access arguments' => array('view', 1), 
     'theme callback' => 'example_theme_callback', 
     'theme arguments' => array($theme), 
    ); 
    } 
    return $items; 
} 

/** 
* Returns an array of the machine named custom themes. 
*/ 
function example_custom_themes() { 
    return array('theme1', 'theme2'); 
} 

/** 
* Does nothing but return the theme name 
*/ 
function example_theme_callback($theme) { 
    return $theme; 
} 

/** 
* Check if the url matches the front page of a theme. If so, suggest front template. 
*/ 
function example_preprocess_page(&$variables) { 
    if (in_array(arg(0), example_custom_themes()) && is_null(arg(1))) { 
    $variables['theme_hook_suggestions'] = 'page__front'; 
    } 
}