【问题标题】:Render joomla component inside same view在同一视图中渲染 joomla 组件
【发布时间】:2015-04-22 19:24:42
【问题描述】:

所以我正在使用 com_content 组件视图, 我需要加载相关的项目 正在查看的那个。 有可能吗?

这是我目前所拥有的:

$com = JPATH_SITE.DS.'components'.DS.'com_content';

if (!class_exists('ContentController')) require($com.DS.'controller.php');
$config['base_path'] = $com;
$cont = new ContentController($config);

JRequest::setVar('view', 'categories');

$lang =& JFactory::getLanguage();
$lang->load('com_content', JPATH_SITE);

$cont->display();

我不知道这是否正是它应该的样子,但如果可能的话,请等待任何帮助。

谢谢

【问题讨论】:

    标签: php joomla render


    【解决方案1】:

    以下是解决方案,适用于我这种情况的任何人:

    // Path to wanted component
    $com = JPATH_SITE.DS.'components'.DS.'com_content';
    
    // Include controller, if its not already include
    if (!class_exists('ContentController')) require($com.DS.'controller.php');
    
    //  Inform controller of its base path
    $config['base_path'] = $com;
    // Init controller 
    $cont = new ContentController($config);
    
    // Get wanted view
    $view =& $cont->getView('category', 'html');
    // Add path to wanted template
    $view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.'ja_wall'.DS.'html'.DS.'com_content'.DS.'category');
    
     // Adding needed params to load info
    JRequest::setVar('view', 'category');
    JRequest::setVar('layout', 'blog');
    JRequest::setVar('Itemid', '102');
    JRequest::setVar('id', $this->item->catid);
    
     // Get and load language
    $lang =& JFactory::getLanguage();
    $lang->load('com_content', JPATH_SITE);
    
    // Render page
    $cont->display();
    

    【讨论】:

      猜你喜欢
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      • 1970-01-01
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多