How can i get other page content?

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
solcito
New Member
New Member
Posts: 3
Joined: Wed Jan 22, 2014 5:34 pm

How can i get other page content?

Post 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!!!
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: How can i get other page content?

Post 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...
solcito
New Member
New Member
Posts: 3
Joined: Wed Jan 22, 2014 5:34 pm

Re: How can i get other page content?

Post 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.
JohnnyB
Dev Team Member
Dev Team Member
Posts: 729
Joined: Tue Nov 21, 2006 5:05 pm
Location: OH, USA

Re: How can i get other page content?

Post 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""
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo

--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
solcito
New Member
New Member
Posts: 3
Joined: Wed Jan 22, 2014 5:34 pm

Re: How can i get other page content?

Post by solcito »

I dont want to run http request twice.
I want to do that in one request.
On php, no in smarty.

Thanks.
kishman155
Translator
Translator
Posts: 169
Joined: Sat Mar 12, 2005 12:30 pm
Location: Vienna

Re: How can i get other page content?

Post 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
Locked

Return to “Developers Discussion”