【问题标题】:Need a duplicate Drupal 7 site with different theme same DB, any suggestions?需要具有不同主题相同数据库的重复 Drupal 7 站点,有什么建议吗?
【发布时间】:2020-01-22 20:11:46
【问题描述】:

我们的根域上有一个 Drupal 7 站点,并希望设置一个包含所有相同内容但没有页眉/页脚品牌的子域或子目录,以便我们的合作伙伴可以将我们产品部分的 iframe 添加到他们的网站。我们需要使用相同的数据库,以便所有内容都能在全球范围内更新。

关于从哪里开始有什么建议吗?感谢您的帮助。

谢谢

【问题讨论】:

    标签: php drupal drupal-7


    【解决方案1】:

    您可以使用自定义模块以编程方式更改主题

    function MYMODULE_menu(){
      $items = array();
      $items['myendpoint/path/%'] = array(
        'title'            => 'Custom rendering page external',
        'page callback'    => 'custom_rendering_on_endpoint',
        'page arguments'   => array(2),
        'access arguments' => array('access content'),
        'type'             => MENU_CALLBACK,
      );
      return $items;
    
    }
    
    
    function custom_rendering_on_endpoint($nid = null)
    
      $node = node_load($nid);
      $view = node_view($node, 'full');
      print drupal_render($view);
    }
    
    function  MYMODULE_custom_theme(){
       $menu = menu_get_item();
       if($menu['path'] == 'myendpoint/path/%'){
           return "custom_theme_name";
       }
       return "default_theme_name";  
    }
    

    注意:更改 page.tpl.php 以删除您不希望在自定义主题中显示的所有区域和部分($header、$footer 等)

    需要注意的是,您要激活的主题必须先在 admin/appearance 中启用。

    文档:https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_custom_theme/7.x

    【讨论】:

    • 谢谢!这正是我想要的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 2021-12-06
    • 2018-03-24
    • 1970-01-01
    相关资源
    最近更新 更多