How can i get other page content?
Posted: Wed Jan 22, 2014 5:42 pm
				
				Hi.
I have this file action.get_content.php on CGExtensions module.
I want to load the html code of the referer page.
How can i do that right?
action.get_content.php code:
Thanks!!!
			I have this file action.get_content.php on CGExtensions module.
I want to load the html code of the referer page.
How can i do that right?
action.get_content.php code:
Code: Select all
            if( !isset($gCms) ) exit;
            clearstatcache();
            $params = array_merge($_GET, $_POST);
            $smarty = cmsms()->GetSmarty();
            $smarty->params = $params;
            clearstatcache();
            
            $page = get_pageid_or_alias_from_url($_SERVER['HTTP_REFERER']); //I change the core function
            $contentops = cmsms()->GetContentOperations();
            $contentobj = $contentops->LoadContentFromAlias($page,true);
            cmsms()->set_variable('content_obj',$contentobj);
            $smarty->assign('content_obj',$contentobj);
            
            cmsms()->set_variable('content_obj',$contentobj);
            cmsms()->set_variable('content_id',$contentobj->Id());
            cmsms()->set_variable('page',$page);
            cmsms()->set_variable('page_id',$page);
            cmsms()->set_variable('page_name',$contentobj->Alias());
            cmsms()->set_variable('position',$contentobj->Hierarchy());
            cmsms()->set_variable('friendly_position',$contentops->CreateFriendlyHierarchyPosition($contentobj->Hierarchy()));         
            
            $smarty->assign('content_obj',$contentobj);
            $smarty->assign('content_id', $contentobj->Id());
            $smarty->assign('page', $page);
            $smarty->assign('page_id', $page);
            $smarty->assign('page_name', $contentobj->Alias());
            $smarty->assign('page_alias', $contentobj->Alias());
            $smarty->assign('position', $contentobj->Hierarchy());
            $smarty->assign('friendly_position', $gCms->variables['friendly_position']);
            error_reporting(1);
            $top  = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"><__html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="he">';
            $body = $smarty->fetch('tpl_body:'.$contentobj->TemplateId());
            $head = $smarty->fetch('tpl_head:'.$contentobj->TemplateId());
            $html = $top.$head.$body;
            
            Events::SendEvent('Core', 'ContentPostRender', array('content' => &$html));
            
            echo $html;
            die;
Thanks!!!