Page 1 of 1

How can i get other page content?

Posted: Wed Jan 22, 2014 5:42 pm
by solcito
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:

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!!!

Re: How can i get other page content?

Posted: Wed Jan 22, 2014 6:18 pm
by Dr.CSS
You can get content from other pages into another page by using CGSimplesmarty, editing any core or module files will most times get you no support in the forum...

Re: How can i get other page content?

Posted: Wed Jan 22, 2014 7:52 pm
by solcito
Thanks.

I dont want the content of the page.
I wasnt the hole html of the page.

It is not a regular page, it is action of some module i created by RegisterRoute.

Re: How can i get other page content?

Posted: Wed Jan 22, 2014 8:46 pm
by JohnnyB
I want to load the html code of the referer page.
I'm not sure if I understand what you need. But, you would use a User Defined Tag to interface with a module or plugin or the CMS core: (http://docs.cmsmadesimple.org/tags/user-defined-tags)

If you are just looking to grab a page's content (data entered into the Content field when editing a page) then use a tag like this any where in a page or template:

{fetch file='http://mysite.com/index.php?page=tests& ... late=false'}

That will grab any CMSMS page without the template. For example, try ""http://www.cmsmadesimple.org/index.php? ... late=false""

Re: How can i get other page content?

Posted: Wed Jan 22, 2014 9:12 pm
by solcito
I dont want to run http request twice.
I want to do that in one request.
On php, no in smarty.

Thanks.

Re: How can i get other page content?

Posted: Mon Mar 03, 2014 1:28 am
by kishman155
Bevor view releases there was an easy way to do this.

With contenttypes.

For some reasons i don't understand they will kick this feature.
you have many ways to do this in the modul.

normaly they want that everybody use smarty for this.

cms_module ist the tag.

Every Page you want to load the modul you need to put the smarty tag
for the module in it.

you could use action to choose which action should be performed.

Please be award, smarty cache all modulecalls.
I disable all the caching in most of my cmsms installations because the
cache is not very reliable.
I also use {nocache}{/nocache} for my modul tag.

i use mod_expires to have better performance.

there should be a content block for modules( {content_module} ) but there is no dokumentation for this or an examble.

hope that helps